
#双指针
fantow
这个作者很懒,什么都没留下…
展开
-
LeetCode题解 -- 双指针(524)
Longest Word in Dictionary through Deleting Given a string and a string dictionary, find the longest string in the dictionary that can be formed by deleting some characters of the given string. If the...原创 2020-03-07 11:17:25 · 163 阅读 · 0 评论 -
LeetCode题解 -- 双指针(141)
Linked List Cycle Given a linked list, determine if it has a cycle in it. To represent a cycle in the given linked list, we use an integer pos which represents the position (0-indexed) in the linked l...原创 2020-03-06 22:42:48 · 164 阅读 · 0 评论 -
LeetCode题解 -- 双指针(680)
Valid Palindrome II Given a non-empty string s, you may delete at most one character. Judge whether you can make it a palindrome. 时间复杂度:O(n^2) 空间复杂度:O(1) 没找到其他的方法,基本上都是这样做的 public boolean validPalindr...原创 2020-03-06 22:09:16 · 246 阅读 · 0 评论 -
LeetCode题解 -- 双指针(345)
Reverse Vowels of a String Write a function that takes a string as input and reverse only the vowels of a string. 时间复杂度:O(n) 空间复杂度:O(n) 代码逻辑类似于快排 public String reverseVowels(String s) { int le...原创 2020-03-06 20:24:54 · 167 阅读 · 0 评论 -
LeetCode题解 -- 双指针(633)
Sum of Square Numbers Given a non-negative integer c, your task is to decide whether there’re two integers a and b such that a2 + b2 = c. 相似题目:LeetCode题解 – 双指针(167) 时间复杂度:O(n) 空间复杂度:O(1) public boolea...原创 2020-03-06 20:07:16 · 121 阅读 · 0 评论 -
双指针问题汇总
优快云某篇博客汇总 Cyc2018原创 2020-03-06 18:26:42 · 154 阅读 · 0 评论 -
LeetCode题解 -- 双指针(88)
88. Merge Sorted Array Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. The number of elements initialized in nums1 and nums2 are m and n respectively. You ...原创 2020-03-06 18:22:59 · 113 阅读 · 0 评论 -
LeetCode题解 -- 双指针(287)
Find the Duplicate Number Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is onl...原创 2020-03-06 17:41:24 · 156 阅读 · 0 评论 -
LeetCode题解 -- 双指针(80)
Remove Duplicates from Sorted Array II Given a sorted array nums, remove the duplicates in-place such that duplicates appeared at most twice and return the new length. Do not allocate extra space for ...原创 2020-03-06 16:33:59 · 468 阅读 · 0 评论 -
LeetCode题解 -- 双指针(26)
Remove Duplicates from Sorted Array Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length. Do not allocate extra space for another...原创 2020-03-06 14:09:27 · 126 阅读 · 0 评论 -
LeetCode题解 -- 双指针(27)
Remove Element Given an array nums and a value val, remove all instances of that value in-place and return the new length. Do not allocate extra space for another array, you must do this by modifying ...原创 2020-03-06 11:53:55 · 206 阅读 · 0 评论 -
LeetCode题解 -- 双指针(42)
Trapping Rain Water Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. 经典的接雨水问题 方法一: 第 i 块区域积水面积 = M...原创 2020-03-05 19:29:01 · 104 阅读 · 0 评论 -
LeetCode题解 -- 双指针(11)
11. Container With Most Water Given n non-negative integers a1, a2, …, an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at ...原创 2020-03-05 16:09:01 · 127 阅读 · 0 评论 -
LeetCode题解 -- 双指针(18)
4Sum Given an array nums of n integers and an integer target, are there elements a, b, c, and d in nums such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum o...原创 2020-03-05 15:43:33 · 95 阅读 · 0 评论 -
LeetCode题解 -- 双指针(16)
3Sum Closest Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each...原创 2020-03-05 14:36:01 · 134 阅读 · 0 评论 -
LeetCode题解 -- 双指针(15)
15. 3Sum Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. 时间复杂度:O(n^2) 空间复杂度:O(1) 先固定第一...原创 2020-03-05 13:08:39 · 119 阅读 · 0 评论 -
LeetCode题解 -- 双指针(167)
167. Two Sum II - Input array is sorted Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number. The function twoSum sh...原创 2020-03-05 12:27:33 · 128 阅读 · 0 评论 -
LeetCode题解 -- 双指针(325)
Maximum Size Subarray Sum Equals k 最大子数组之和为k Given an array nums and a target value k, find the maximum length of a subarray that sums to k. If there isn’t one, return 0 instead. Given nums = [1, -1, ...原创 2020-03-05 10:40:18 · 318 阅读 · 0 评论