<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Two Pointers on prometheus</title><link>https://new.halfrost.com/zh/tags/two-pointers/</link><description>Recent content in Two Pointers on prometheus</description><generator>Hugo -- gohugo.io</generator><language>zh-CN</language><copyright>halfrost</copyright><lastBuildDate>Sat, 21 Sep 2019 10:07:00 +0000</lastBuildDate><atom:link href="https://new.halfrost.com/zh/tags/two-pointers/index.xml" rel="self" type="application/rss+xml"/><item><title>Algorithm in LeetCode —— Two Pointers</title><link>https://new.halfrost.com/zh/two_pointers/</link><pubDate>Sat, 21 Sep 2019 10:07:00 +0000</pubDate><guid>https://new.halfrost.com/zh/two_pointers/</guid><description>Two Pointers 的 Tips: 双指针滑动窗口的经典写法。右指针不断往右移，移动到不能往右移动为止(具体条件根据题目而定)。当右指针到最右边以后，开始挪动左指针，释放窗口左边界。第 3 题，第 76 题，第 209 题，第 424 题，第 438 题，第 567 题，第 713 题，第 763 题，第 845 题，第 881 题，第 904 题，第 978 题，第 992 题，第 1004 题，第 1040 题，第 1052 题。 left, right := 0, -1 for left &amp;lt; len(s) { if right+1 &amp;lt; len(s) &amp;amp;&amp;amp; freq[s[right+1]-&amp;#39;a&amp;#39;] == 0 { freq[s[right+1]-&amp;#39;a&amp;#39;]++ right++ } else { freq[s[left]-&amp;#39;a&amp;#39;]-- left++ } result = max(result, right-left+1) } 快慢指针可以查找重复数字，时间复杂度 O(n)，第 287 题。 替换字母以后，相同字母能出现连续最长的长度。第 424 题。 SUM 问题集。第 1 题，第 15 题，第 16 题，第 18 题，第 167 题，第 923 题，第 1074 题。 Title Solution Difficulty Time Space 收藏 3.</description></item></channel></rss>