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.
nope i read it correctly first time, its "any pair" not just the number next door. so for 4,3,3,2,2,1 your best choice is {3,3,2,2} since 4 is more then 1 away from 2 and 1. this subset choice would be the same completely ignoring the order the numbers appear. so 3,1,2,4,2,3 is essentially the same problem as above
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 →
nope i read it correctly first time, its "any pair" not just the number next door. so for 4,3,3,2,2,1 your best choice is {3,3,2,2} since 4 is more then 1 away from 2 and 1. this subset choice would be the same completely ignoring the order the numbers appear. so 3,1,2,4,2,3 is essentially the same problem as above