• + 0 comments

    Thanks for the explanation. For the later part of this solution, one can use a binary tree to perform the comparison. Let the size of the set containing the pruned numbers on the above with leading 0 be M (the numbers at and above the line A), with leading 1 be K, rather then O(M*K) comparison, binary tree provides a complexity O(M+K).