Count number of ways to cover a distance - GeeksforGeeks
Count number of ways to cover a distance Given a distance 'dist, count total number of ways to cover the distance with 1, 2 and 3 steps. Examples: Input: n = 3 Output: 4 Below are the four ways 1 step + 1 step + 1 step 1 step + 2 step 2 step + 1 step 3 step Input: n = 4 Output: 7 We strongly recommend you to minimize your browser and try this yourself first. // A naive recursive C++ program to count number of ways to cover // a distance with 1, 2 and 3 steps #includeRead full article from Count number of ways to cover a distance - GeeksforGeeks
No comments:
Post a Comment