MCPcopy Create free account
hub / github.com/Tiwarishashwat/InterviewCodes / f

Method f

MaximumEmployeesToBeInvitedToAMeeting.java:46–61  ·  view source on GitHub ↗
(int node, int skip, List<List<Integer>> reverseList)

Source from the content-addressed store, hash-verified

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}

Callers 1

maximumInvitationsMethod · 0.95

Calls 1

isEmptyMethod · 0.45

Tested by

no test coverage detected