1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| int findSubstring(String s) { int[] map = new int[256]; int counter; int begin = 0, end = 0; int d; for () { } while (end < s.length()) { if (map[s[end++]]-- ?) { } while () { if (map[s[begin++]]++ ?) { } } } return d; }
|
Related Problems:
Ref: https://discuss.leetcode.com/topic/30941/here-is-a-10-line-template-that-can-solve-most-substring-problems