We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Sorry for the delay. Your idea is basically correct but it doesn't consider the case that there exists duplicate values. Here is an example:
[1,8,7,6,2,3,2,4,2,5,2,6]. With your method, the answer is 3. However, it actually takes 7 days to reach the end because we have dupicate values here. Hope it helps!
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Poisonous Plants
You are viewing a single comment's thread. Return to all comments →
Sorry for the delay. Your idea is basically correct but it doesn't consider the case that there exists duplicate values. Here is an example: [1,8,7,6,2,3,2,4,2,5,2,6]. With your method, the answer is 3. However, it actually takes 7 days to reach the end because we have dupicate values here. Hope it helps!