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.
A solution for nlogn can be -Take element one by one and subtract it with the sum u wanna achieve and then instead of searching the array linearly keep the sorted array with u and search in it using binary search only if the element is there do a linear search on the original array
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Ice Cream Parlor
You are viewing a single comment's thread. Return to all comments →
A solution for nlogn can be -Take element one by one and subtract it with the sum u wanna achieve and then instead of searching the array linearly keep the sorted array with u and search in it using binary search only if the element is there do a linear search on the original array