Friday, October 27, 2017

[LeetCode]Longest Substring with At Most Two Distinct Characters


Longest Substring without Repeating Character是非常类似的题目,区别只是条件稍有不同,本质的做法都是一样的。可以用sliding window解,时间复杂度O(n),空间复杂度O(n),代码如下:


No comments:

Post a Comment