Find top-K frequent values with tiebreaks | Meta Interview Question