- find successors and predecessors using BST (both list will be sorted); in the end, we can easily get top k from the two sorted list - with BST: **inorder traversal gives us sorted predecessors - ...
Given an array nums of size n, return the majority element. The majority element is the element that appears more than ⌊n / 2⌋ times. You may assume that the majority element always exists in the ...