Big P and The Road Less Travelled
Practice
3.6 (8 votes)
Algorithms
Approved
Dynamic programming
Medium
Open
Problem
85% Success 2798 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Big P is willing to climb up a hill. The hill is divided into several checkpoints where the travelers can buy water,food etc for their trip.

At each checkpoint there are several roads that go up to other checkpoints (Not necessarily the next checkpoint).

Now Big P is standing at the base of the hill i.e at checkpoint 1 and wants to know the total number of ways he could climb to the top of the hill i.e the last checkpoint N.

Input Format:
First line contains an integer N,the total number of checkpoints on the hill. Next lines contain a pair of integers (x,y) denoting a directed path from checkpoint x to checkpoint y until a - (0 0) is in the input.

Note: Base of Hill , where Big P is standing is Checkpoint #1 and the top of the hill is Checkpoint #N

Output Format:
A single integer X , denoting the total number of paths from the base of the hill to it's top.

[N<=10000 , 1<=x,y<=N]

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
6 votes
Tags:
Data StructuresDepth First SearchAlgorithmsDisjoint Set UnionGraphs
Points:30
8 votes
Tags:
AlgorithmsDepth First SearchGraphsMediumOpen
Points:30
6 votes
Tags:
AlgorithmsDepth First SearchGraphsGreedy AlgorithmsMediumSortingTrees