![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
双指针
码不停Ti
信息安全在校大学生
展开
-
【LeetCode】42. 接雨水
给定n 个非负整数表示每个宽度为 1 的柱子的高度图,计算按此排列的柱子,下雨之后能接多少雨水。上面是由数组 [0,1,0,2,1,0,1,3,2,1,2,1] 表示的高度图,在这种情况下,可以接 6 个单位的雨水(蓝色部分表示雨水)。感谢 Marcos 贡献此图。示例:输入: [0,1,0,2,1,0,1,3,2,1,2,1]输出: 6在真实的面试中遇到过这道题?来源...原创 2020-01-11 12:26:46 · 354 阅读 · 0 评论 -
【LeetCode】977. Squares of a Sorted Array数组 双指针
Given an array of integers Asorted in non-decreasing order,return an array of the squares of each number,also in sorted non-decreasing order.Example 1:Input: [-4,-1,0,3,10]Output: [0,1,9,16...原创 2019-12-11 20:18:43 · 418 阅读 · 0 评论 -
【LeetCode】88. 合并两个有序数组 双指针
给定两个有序整数数组nums1 和 nums2,将 nums2 合并到nums1中,使得num1 成为一个有序数组。说明:初始化nums1 和 nums2 的元素数量分别为m 和 n。你可以假设nums1有足够的空间(空间大小大于或等于m + n)来保存 nums2 中的元素。示例:输入:nums1 = [1,2,3,0,0,0], m = 3nums2 = ...原创 2019-12-11 19:48:09 · 379 阅读 · 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 list where tail co...原创 2019-12-10 11:23:49 · 323 阅读 · 0 评论 -
【Leet Code】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 array, you must do this by modifyi...原创 2019-09-27 13:45:38 · 368 阅读 · 0 评论 -
【Leet Code】19. Remove Nth Node From End of List
19. Remove Nth Node From End of ListGiven a linked list, remove then-th node from the end of list and return its head.Example:Given linked list: 1->2->3->4->5, and n = 2.After re...原创 2019-10-02 23:41:56 · 290 阅读 · 0 评论 -
【LeetCode】 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 (i, ai) and (i, 0). Find two...原创 2019-10-03 00:57:07 · 269 阅读 · 0 评论 -
【Leet Code】283. Move Zeroes
Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.Example:Input: [0,1,0,3,12]Output: [1,3,12,0,0]Note:You mus...原创 2019-10-04 20:16:05 · 314 阅读 · 0 评论 -
【LeetCode】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.Note:The solution set must not cont...原创 2019-10-07 17:29:42 · 279 阅读 · 0 评论