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 think the question asks that a number be chosen from the array
such that the difference between any 2 chosen numbers is less
than 2.
for example,
s = [4,6,7,4,6,4,6]
here, if 6 is chosen, then 7 is next number to choose.then, the next number n sould be such that |7-n| <2 and |6-n|<2
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Picking Numbers
You are viewing a single comment's thread. Return to all comments →
i think the question asks that a number be chosen from the array such that the difference between any 2 chosen numbers is less than 2. for example, s = [4,6,7,4,6,4,6] here, if 6 is chosen, then 7 is next number to choose.then, the next number n sould be such that |7-n| <2 and |6-n|<2