Shortest Snippet. Given a sequence [A, x, x, B, A, x, B], return the shortest sub-sequence for the given query [A, B]. Returns: [A, x, B]
Anonymous
First, save all positions for the each character in the query in a hash. Then calculate the minimum difference between positions with two pointers, one for each array.
Check out your Company Bowl for anonymous work chats.