Skip to content

Commit

Permalink
GPT being GPT
Browse files Browse the repository at this point in the history
  • Loading branch information
huynhtrankhanh authored Mar 2, 2024
1 parent 81f866e commit 52c0c23
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions compiler/findCycle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,16 @@ export function findCycle(edges: [number, number][]): number[] | undefined {
let path: number[] = []

edges.forEach(([from, to], i) => {
// Note: no adjustment done for 0-index here as input is already in 0-index
head[from]++
})

for (let i = 1; i <= n; i++) {
head[i] += head[i - 1]
}

let tempHead = [...head]
edges.forEach(([from, to], i) => {
values[tempHead[from] - 1] = to
tempHead[from]--
values[head[from] - 1] = to
head[from]--
})

const dfs = (vertex: number) => {
Expand Down

0 comments on commit 52c0c23

Please sign in to comment.