deftwo_pointers(self, nums): for i in range(len(nums)): <calculate condition such as char_to_count> while <meets condition>: res = min(res, i - left + 1) <anti-calculate condition such as char_to_count> left += 1 return <result>
求最长串
Python代码:
1 2 3 4 5 6 7 8
deftwo_pointers(self, nums): for i in range(len(nums)): <calculate condition such as char_to_count> while <does not meet condition>: <anti-calculate condition such as char_to_count> left += 1 res = max(res, i - left + 1) return <result>