SRM 719, D2, 250-Pointer (LongLiveZhangzj)

James S. Plank

Thu Sep 14 11:21:29 EDT 2017
With the constraints being so low, a simply double-nested for loop will work. However, being the good computer scientist that you, dear reader, are, you will naturally take offense at writing an O(n2) solution to this problem.

Instead, insert the words in words into a set, and then for each word in speech(), try to find it in the set. Now your solution is O(n log n), and all is right with the universe.