Hello👋,
My name is Alex and I'm maker of Devmates.co. 😊
We are resolving daily coding problems which asked by top tech companies together. We share our solutions, give some help if anyone stuck, support each other and just hangout together in the internet. 🍻☕️💬
I get this problem from our members or just searching them in the internet(leetcode forums, Glassdoor, teamblind, etc.). Sometimes this problem can be very easy, sometimes too 👷♂️hard, everything depends on skills but we are trying to resolve all of them and Have Fun. 🙌
Today I want to share problem which was asked by 🏢Microsoft.
Problem:
Given an array containing numbers 1 to n where array[i] = i+1.
Find the minimum number of jumps required from arr[0] to arr[n-1].
From current position i, we can jump to positions i+1, i+2, i+3 and I+4
There are optional boosters given in the form of an object like - {1: 15, 5: 10} which means, if we reached at index 1 we can directly jump to index 15 similarly, if we reached at index 5, we can directly jump to index 10.
Example:
Input:
arr = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
boosters = {3: 8, 5:10}
Output: 4
Why: (1 -> 5 -> 10 -> 14 -> 15)
🙌 Don't hesitate to share your solutions directly on devmates.co
Top comments (0)