4 ms·
> comprehend code solutions to Leetcode-like problems What were you supposed to comprehend? The name of the function was “containsSubstring” and it… checked t
by commandlinefan 4y ago
> comprehend code solutions to Leetcode-like problems
What were you supposed to comprehend? The name of the function was “containsSubstring” and it… checked to see if a string contained a substring. Was there supposed to be a bug in there? If there was, I didn’t see it (although I didn’t spend too terribly long looking for one). The “containsSubstring” variable was unnecessary (it could have just returned true on line 13), but that seems awfully nitpicky.
- shultays 4y agoMaybe author means that it is iterating all the way up to len(input) instead of len(input) - len(word) Or instead of checking j == len(word)-1 inside the inner loop, you could do that outside, after the loop and return true there Both are a lot more nitpicky. But author's point is the code is not "wrong" but it is not great either