Minimum number of jumps to reach end | Jump Game II

This question is based on ladder and stairs, We need to find the minimum number of jumps to reach the end.

Here we will follow few steps:

  1. initialize stairs and ladder as the first element of the array.
  2. Keep track of the maximum ladder we got as of now.
  3. decrease the stairs as we climb up.
  4. if stairs become zero in the current ladder make a jump to another ladder and recalculate the stairs left in that ladder to reach the top(stairs = ladder level)

Below is the implementation of the code.

Happy Coding!

Software Developer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store