Stop piping grep into five other commands. It already handles most of that.
Firstly meant to get you up and running easily, not necessarily to provide everything that might be useful and in the most efficient manner. Creating string lite I've had a look at the C++ standard, ...
// Time Complexity: O(n²) (due to substring creation and window reset) } else if (right == s.length() - 1 && !(map.containsKey(s.substring(left, right + 1)))) { map ...