Want quant roles sent to your inbox?

Get quant job listings, interview prep resources, and industry news delivered to you for free.

No spam. Unsubscribe anytime.

dijkstra

Programming Interview
Questions

← Back

dijkstra

Suppose you are modeling the relationships between stocks in a market, where each stock is a node and there is an edge between two nodes if the correlation between them exceeds a certain threshold.

Create a function dijkstra(graph, start, end) that find the "shortest" path between two stocks (nodes) in terms of the least correlation.

Return the value of the shortest path between start and end, by traversing through graph.

Example 1:

  • graph: { 'A': {'B': 0.2}, 'B': {'A': 0.2, 'C': 0.3}, 'C': {'A': 0.5, 'B': 0.3} }
  • start: 'A'
  • End: 'B'

Output: 0.5 (because A -> B -> C costs 0.2 + 0.3 = 0.5).

If there is no path between the start and the end within the graph, return 'invalid'.

Not Completed

Completed!

decreasing_prices.py

Tests - to submit your code!

symbol symbol

Efficiency

symbol symbol

Test Case 1

symbol symbol

Test Case 2

symbol symbol

Test Case 3

symbol symbol

Test Case 4

symbol symbol

Test Case 5

symbol symbol

Test Case 6

symbol symbol

Test Case 7

symbol symbol

Test Case 8

symbol symbol

Test Case 9

symbol symbol

Test Case 10

symbol Submit to See Results

symbol Submit to See Results

symbol Submit to See Results

symbol Submit to See Results

symbol Submit to See Results

symbol Submit to See Results

symbol Submit to See Results

symbol Submit to See Results

symbol Submit to See Results

symbol Submit to See Results

symbol Submit to See Results

Join our Newsletter and Receive the Latest Updates!

Main Links

Academy Trade Courses Assessments Interview Prep Contact Us

Social Media

Facebook Instagram YouTube

Legal

Terms and Conditions

Talent Acquisition

Looking to hire exceptional quant talent?

© 2026 EverythingQuant. All Rights Reserved.