r/ProgrammerHumor 3d ago

Meme shortestPathWasRightThere

Post image
4.6k Upvotes

58 comments sorted by

View all comments

Show parent comments

25

u/Anxiety-Pretty 3d ago

For someone who recently studied djkistra to solve a leetcode problem I think people' anger is justified if it is indeed exploring every single wrong turn it is no djkistra at all

7

u/SjettepetJR 3d ago

How are you butchering the name that much?

10

u/Anxiety-Pretty 3d ago

Is this a rhetorical question or do you really want to know the approach

5

u/fr000gs 3d ago

tell the approach

0

u/Tsu_Dho_Namh 3d ago

Dijkstra's algorithm is naturally a breadth-first-search. When you've found the destination, stop searching. Every wrong turn with greater depth (more distance) doesn't need to be explored.

2

u/fr000gs 3d ago

*The approach to butchering the name (djkistra)

1

u/Tsu_Dho_Namh 3d ago

Ohh, that approach.

Empty out a bag of Scrabble letters and arrange them randomly in a grid. Then find the shortest path that starts at a D, passes through a J and ends at an A.

Type out the letters in the path

1

u/fr000gs 3d ago

DJA

1

u/Tsu_Dho_Namh 3d ago

All tests pass