Skip to content

Commit e2a8edc

Browse files
committed
update states name
1 parent 677ff2b commit e2a8edc

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

‎685. Redundant Connection II.js‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,22 @@
2525
};
2626

2727
function hasCycle(start, edgesObj, states) {
28-
if(states[start]===-1) return false
29-
if(states[start]===1) return true
30-
states[start] = 1
28+
if(states[start]==='NO_CYCLE') return false
29+
if(states[start]==='CYCLE') return true
30+
states[start] = 'CYCLE'
3131
if(start in edgesObj) {
3232
for(let destKey of edgesObj[start]) {
3333
if(hasCycle(destKey, edgesObj, states)) return true
3434
}
3535
}
36-
states[start] = -1
36+
states[start] = 'NO_CYCLE'
3737
return false
3838
}
3939

4040
function createStates(edges) {
4141
const states = {}
4242
for(let i=1; i<=edges.length; i++) {
43-
states[i] = 0
43+
states[i] = 'UNVISITED'
4444
}
4545
return states
4646
}

0 commit comments

Comments
 (0)