Cisco 2024 Papers
Previous year papers with coding questions
Practice Cisco placement paper coding questions with detailed solutions. Access Cisco OA coding problems in Java, C++, Python.
This page contains Cisco coding questions from Cisco OA placement papers with detailed solutions.
Cisco OA Coding Section:
Solution (Java):
public int networkDelayTime(int[][] times, int n, int k) { Map<Integer, List<int[]>> graph = new HashMap<>(); for (int[] time : times) { graph.computeIfAbsent(time[0], x -> new ArrayList<>()) .add(new int[]{time[1], time[2]}); }
PriorityQueue<int[]> pq = new PriorityQueue<>((a, b) -> a[1] - b[1]); pq.offer(new int[]{k, 0}); Map<Integer, Integer> dist = new HashMap<>();
while (!pq.isEmpty()) { int[] curr = pq.poll(); int node = curr[0], time = curr[1]; if (dist.containsKey(node)) continue; dist.put(node, time);
if (graph.containsKey(node)) { for (int[] edge : graph.get(node)) { int next = edge[0], weight = edge[1]; if (!dist.containsKey(next)) { pq.offer(new int[]{next, time + weight}); } } } }
if (dist.size() != n) return -1; return Collections.max(dist.values());}Time Complexity: O(E log V)
Cisco 2024 Papers
Previous year papers with coding questions
Cisco Main Page
Complete Cisco placement guide
Practice Cisco coding questions regularly!