Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Create a program to implement the Dijkstra algorithm for finding the shortest path in a graph.

Hard

Problem Statement

Create a program to implement the Dijkstra algorithm for finding the shortest path in a graph.

Sample Input

Graph: { "nodes": [0, 1, 2], "edges": [[0, 1, 4], [0, 2, 1], [2, 1, 2]] }

Sample Output

Vertex 	 Distance from Source
0 	 0
1 	 4
2 	 1

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
using System; using System.Collections.Generic; class DijkstraAlgorithm { static void Main() { // Implement Dijkstra algorithm for the given graph } }
Log in or sign up to run or submit your code.Log inSign up
Input
Graph: { "nodes": [0, 1, 2], "edges": [[0, 1, 4], [0, 2, 1], [2, 1, 2]] }
Expected Output
Vertex 	 Distance from Source
0 	 0
1 	 4
2 	 1