Skip to content

Cisco Coding Questions - DSA Problems & Solutions

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:

  • Problems: 2-3 coding problems
  • Time: 90 minutes
  • Languages: C++, Java, Python
Q1: Find the minimum time for a signal to reach all nodes in a network.

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)


Practice Cisco coding questions regularly!