BackmediumRecursion Infosys Microsoft

Interstellar Route Planner Solution

Problem Statement

In a galaxy with n planetary systems, space travelers can only jump 3 or 5 systems at a time. Given a final destination, calculate the number of unique routes to reach it.

Example 1
Input
n = 5, final destination = 15
Output
2

Explanation: Step-by-step: We can reach the final destination 15 by jumping 3 or 5 systems at a time. The two unique routes are 3+3+3+3+3=15 and 5+5+5=15.

Example 2
Input
n = 4, final destination = 12
Output
1

Explanation: Step-by-step: We can reach the final destination 12 by jumping 3 or 5 systems at a time. The only unique route is 3+3+3+3=12.

Constraints

  • Input will be a positive integer
  • Input will not exceed 50
Live Compiler
Loading...
Test Cases & Output
🔒 Sign up to run your code

🚀 Practice this problem

Run code, get AI hints & track streak

Sign Up Free