cycle nodes와 safe nodes를 구분하여 safe nodes를 오름차순으로 반환하라
class Solution {
public List<Integer> eventualSafeNodes(int[][] graph) {
/*
n == graph.length
1 <= n <= 10^4
0 <= graph[i].length <= n
graph[i] is sorted in a strictly increasing order
*/
List<Integer> answer = new ArrayList<Integer>();
int cnt = 0;
for(int[] arr: graph){
System.out.print("idx :" + cnt + " items -> ");
for(int temp : arr){
System.out.print(temp);
}
System.out.println();
cnt++;
}
return answer;
}
}
상태 파악하기 위한 코드
idx :0 items -> 12
idx :1 items -> 23
idx :2 items -> 5
idx :3 items -> 0
idx :4 items -> 5
idx :5 items ->
idx :6 items ->
'Algorithm > LeetCode' 카테고리의 다른 글
[LeetCode] Check if Word Equals Summation of Two Words (0) | 2021.06.07 |
---|---|
[Quiz] Find-Eventual-Safe-States (0) | 2021.05.26 |
[LeetCode] - Most Common Word (0) | 2021.05.12 |
[LeetCode] - LFU Cache (0) | 2021.05.11 |
[LeetCode] - Linked List Cycle (0) | 2021.05.11 |