LeetCode常见题型——双指针

1. 算法思想

双指针主要用于遍历数组,协同完成任务,也可延伸到多数组多指针。

若双指针指向同一数组,遍历方向相同且不会相交,则为滑动窗口,常用于区间搜索。

若双指针只想同一数组,但遍历方向相反,则可用来搜索排好序的数组。

C++指针尤为重要,可以有很多特别的操作。

2. 常见题型

LeetCode-1. Two Sum [C++]_贫道绝缘子的博客-CSDN博客Given an array of integers, returnindicesof the two numbers such that they add up to a specific target.https://blog.csdn.net/qq_15711195/article/details/122143418LeetCode-167. Two Sum II - Input Array Is Sorted [C++][Java]_贫道绝缘子的博客-CSDN博客Given a1-indexedarray of integersnumbersthat is alreadysorted in non-decreasing order, find two numbers such that they add up to a specifictargetnumber.https://blog.csdn.net/qq_15711195/article/details/122995459LeetCode-88. Merge Sorted Array [C++][Java]_贫道绝缘子的博客-CSDN博客You are given two integer arraysnums1andnums2, sorted innon-decreasing order, and two integersmandn, representing the number of elements innums1andnums2respectively. Mergenums1andnums2into a single array sorted innon-decreasing order.https://blog.csdn.net/qq_15711195/article/details/123011151LeetCode-141. Linked List Cycle [C++][Java]_贫道绝缘子的博客-CSDN博客Givenhead, the head of a linked list, determine if the linked list has a cycle in it.https://blog.csdn.net/qq_15711195/article/details/122519333?spm=1001.2014.3001.5502LeetCode-142. Linked List Cycle II [C++][Java]_贫道绝缘子的博客-CSDN博客Given theheadof a linked list, returnthe node where the cycle begins. If there is no cycle, returnnull.https://blog.csdn.net/qq_15711195/article/details/122519693LeetCode-76. Minimum Window Substring [C++][Java]_贫道绝缘子的博客-CSDN博客Given two stringssandtof lengthsmandnrespectively, returntheminimum window substringofssuch that every character int(including duplicates) is included in the window.https://blog.csdn.net/qq_15711195/article/details/122852073?spm=1001.2014.3001.5502LeetCode-633. Sum of Square Numbers [C++][Java]_贫道绝缘子的博客-CSDN博客Given a non-negative integerc, decide whether there're two integersaandbsuch thata2+ b2= c.https://blog.csdn.net/qq_15711195/article/details/123011466LeetCode-5. Longest Palindromic Substring [C++][Java]_贫道绝缘子的博客-CSDN博客Given a strings, returnthe longest palindromic substringins.https://blog.csdn.net/qq_15711195/article/details/122833115LeetCode-680. Valid Palindrome II [C++][Java]_贫道绝缘子的博客-CSDN博客Given a strings, returntrueif thescan be palindrome after deletingat most onecharacter from it.https://blog.csdn.net/qq_15711195/article/details/123011663LeetCode-524. Longest Word in Dictionary through Deleting [C++][Java]_贫道绝缘子的博客-CSDN博客Given a stringsand a string arraydictionary, returnthe longest string in the dictionary that can be formed by deleting some of the given string characters. If there is more than one possible result, return the longest word with the smallest lexicographhttps://blog.csdn.net/qq_15711195/article/details/123012002LeetCode-340. Longest Substring with At Most K Distinct Characters [C++][Java]_贫道绝缘子的博客-CSDN博客Given a string, find the length of the longest substring T that contains at mostkdistinct characters.https://blog.csdn.net/qq_15711195/article/details/123012183LeetCode-3. Longest Substring Without Repeating Characters [C++][Java]_贫道绝缘子的博客-CSDN博客Given a strings, find the length of thelongest substringwithout repeating characters.https://blog.csdn.net/qq_15711195/article/details/122817429?spm=1001.2014.3001.5502

参考文献

【1】C/C++指针详解之基础篇

【2】C/C++指针详解之提高篇

【3】C/C++函数指针与指针函数等区别

你可能感兴趣的:(LeetCode刷题怪,leetcode,算法,职场和发展)