(int node, int skip, List<List<Integer>> reverseList)
| 44 | return Math.max(max2lenCyclePath,longestCycle); |
| 45 | } |
| 46 | private int f(int node, int skip, List<List<Integer>> reverseList){ |
| 47 | int len=0; |
| 48 | // [node, len] |
| 49 | Queue<int[]> queue = new LinkedList<>(); |
| 50 | // queue.offer(node); |
| 51 | queue.offer(new int[]{node, 0}); |
| 52 | while(!queue.isEmpty()){ |
| 53 | int cur[] = queue.poll(); |
| 54 | len = Math.max(len, cur[1]); |
| 55 | for(int neighbour:reverseList.get(cur[0])){ |
| 56 | if(neighbour == skip) continue; |
| 57 | queue.offer(new int[]{neighbour, cur[1] + 1}); |
| 58 | } |
| 59 | } |
| 60 | return len; |
| 61 | } |
| 62 | } |
no test coverage detected