Top K Votes

Given a list of votes of pairs. Return top k votes up to a certain timestamp. TreeSet When need this kind floor/ceiling type of operations, considering using tree set. lower()/higher()/headSet()/tailSet() Use priority queue to find top k. This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To […]

Number of Matching Subsequences

A prerequisite problem is to determine whether a string s is a subsequence of text t. Updating Search Range The core idea is we iterating chars from the string s in a certain range (initialized to [0, t.length() – 1]), and each time we found a match, we update the next char’s search range to […]