• + 0 comments

    Binary search for every element is O(nlogn). For this problem (arr[i] belongs to [0, 20000] we can use a bucket, hence O(n) time space.

    https://www.hackerrank.com/challenges/beautiful-triplets/forum/comments/588430