Menu
Coddy logo textTech

Final Challenge #1

Lesson 8 of 9 in Coddy's Dijkstra's Algorithm - Graph Algorithms course.

challenge icon

Challenge

Medium

Often you only care about one destination.

Write a function named shortestDistance that takes n, the flat edges array (triples, directed), a source, and a target, and returns the shortest distance from source to target, or -1 if target is unreachable.

Try it yourself

#include <stdlib.h>

int shortestDistance(int n, int* edges, int edges_size, int source, int target) {
    // Write code here
    return -1;
}

All lessons in Dijkstra's Algorithm - Graph Algorithms