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.
By problem statement itself, it's very clear that we need to worry about numbers that are adjacent or equal(i.e. absolute difference<=1). freq[] has got frequency of occurance of each element of input array. We just need to return which two adjacent elements appear highest in array.(sum of their frequencies)
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 →
By problem statement itself, it's very clear that we need to worry about numbers that are adjacent or equal(i.e. absolute difference<=1). freq[] has got frequency of occurance of each element of input array. We just need to return which two adjacent elements appear highest in array.(sum of their frequencies)