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.
I don't quite understand this line in the second half of your code:
(markings[i] > markings[i+1] && (markings[i+1] + 1) > markings[i])
this logically translates to "markings[i] > markings[i+1] && markings[i] <= markings[i+1]", which will always evaluate to false...and thus candies[i] will be assigned to candies[i] every time...so how exactly will this still work as intended?
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Candies
You are viewing a single comment's thread. Return to all comments →
I don't quite understand this line in the second half of your code: (markings[i] > markings[i+1] && (markings[i+1] + 1) > markings[i])
this logically translates to "markings[i] > markings[i+1] && markings[i] <= markings[i+1]", which will always evaluate to false...and thus candies[i] will be assigned to candies[i] every time...so how exactly will this still work as intended?