
Two Pointers
小·幸·运
你的所有努力最后都会回赠予你。
展开
-
LeetCode--532. K-diff Pairs in an Array
Given an array of integers and an integer k, you need to find the number of unique k-diff pairs in the array. Here a k-diff pair is defined as an integer pair (i, j), where i and j are both numbers in...原创 2018-06-02 21:18:27 · 169 阅读 · 0 评论 -
LeetCode--696. Count Binary Substrings
Give a string s, count the number of non-empty (contiguous) substrings that have the same number of 0's and 1's, and all the 0's and all the 1's in these substrings are grouped consecutively. Substrin...原创 2018-07-09 20:35:47 · 175 阅读 · 0 评论 -
LeetCode--459. Repeated Substring Pattern
Given a non-empty string check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. You may assume the given string consists of lowercase Engl...原创 2018-06-14 21:44:07 · 151 阅读 · 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.Example 1:Given s = "hello", return "holle".Example 2:Given s = "leetcode", return "leotcede".Note:The vowels does...原创 2018-06-12 22:10:28 · 180 阅读 · 0 评论 -
LeetCode--88. Merge Sorted Array
Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:The number of elements initialized in nums1 and nums2 are m and n respectively.You may assume that nums...原创 2018-05-29 19:53:55 · 175 阅读 · 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 array, you must do this by modifying...原创 2018-05-29 19:19:06 · 137 阅读 · 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 the input array ...原创 2018-05-29 16:11:10 · 162 阅读 · 0 评论 -
LeetCode-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 must do th...原创 2018-05-29 15:43:31 · 116 阅读 · 0 评论 -
LeetCode--125. Valid Palindrome
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.Note: For the purpose of this problem, we define empty string as valid palindrome.Example 1...原创 2018-06-11 20:46:45 · 99 阅读 · 0 评论 -
LeetCode-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 should return indices of the two numbers su...原创 2018-05-28 21:00:07 · 134 阅读 · 0 评论 -
PAT甲级A1029 Median(25 分)
Given an increasing sequence S of N integers, the median is the number at the middle position. For example, the median of S1 = { 11, 12, 13, 14 } is 12, and the median of S2 = { 9, 10, 15, 16, 17 } is...原创 2018-08-17 22:06:22 · 662 阅读 · 0 评论