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.
Picking Numbers
Picking Numbers
Sort by
recency
|
2534 Discussions
|
Please Login in order to post a comment
For Sample Input 0
6 4 6 5 3 3 1
{4,3,3} is NOT a subarray of the input array. Subarrays are contiguous. Does anyone proofread these before they are posted?
I'd vent more but this page appears to not have been tested on Safari. FFS. Ignore all text bdlow this that I can't access when editing.
3 Explanation 0 We choose the following multiset of integers from the array: . Each pair in the multiset has an absolute difference (i.e., and ), so we print the number of chosen integers, , as our answer.
C#: O(nlogn)
public static int pickingNumbers(List a) { if (a.Count <= 1) return a.Count;
}
my python solution.:
Here is my O(n) c++ solution, you can find the explanation here : https://youtu.be/0zvqEO1gDRw
solution Java.