Skip to content

Latest commit

 

History

History

shortest_path

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Shortest path from 1 to n Basic Accuracy: 50.93% Submissions: 15500 Points: 1 Consider a directed graph whose vertices are numbered from 1 to n. There is an edge from a vertex i to a vertex j iff either j = i + 1 or j = 3 * i. The task is to find the minimum number of edges in a path in G from vertex 1 to vertex n.

Example 1:

Input: N = 9 Output: 2 Explanation: 9 -> 3 -> 1, so number of steps are 2.