- 博客(31)
- 资源 (1)
- 收藏
- 关注
原创 [leetcode] 【链表】 82. Remove Duplicates from Sorted List II
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example,Given 1->2->3->3->4->4->5, return 1->2->5.Given 1
2016-05-30 17:28:26 181
原创 [leetcode] 【链表】83. Remove Duplicates from Sorted List
Given a sorted linked list, delete all duplicates such that each element appear only once.For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, return 1->2->3.题意一个排好序的链表,把 里面的重复元
2016-05-30 17:04:32 217
原创 [leetcode] 【链表】86. Partition List
Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should preserve the original relative order of the nodes in each of
2016-05-30 16:43:35 214
原创 [leetcode] 【链表】92. Reverse Linked List II
Reverse a linked list from position m to n. Do it in-place and in one-pass.For example:Given 1->2->3->4->5->NULL, m = 2 and n = 4,return 1->4->3->2->5->NULL.Note:Given m, n satisfy the
2016-05-30 15:40:10 304
原创 [leetcode] 【链表】2. Add Two Numbers
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a link
2016-05-30 11:12:49 187
原创 [leetcode] 第一类--【数组】 题大纲
第一类关于数组的题都写完了,大多数都还是比较经典的题。在学习的路上,大家一起努力~60. Permutation Sequence 36. Valid Sudoku42. Trapping Rain Water48. Rotate Image26. Remove Duplicates from Sorted Array80. Remove Duplicat
2016-05-30 10:56:47 342
原创 [leetcode] 【数组】 137. Single Number II
Given an array of integers, every element appears three times except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without u
2016-05-30 10:32:18 256
原创 [leetcode] 【数组】 136. Single Number
Given an array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without using e
2016-05-30 10:21:59 227
原创 [leetcode] 【数组】 135. Candy
There are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requirements:Each child must have at least on
2016-05-29 23:23:09 435
原创 [leetcode] 【数组】134. Gas Station
There are N gas stations along a circular route, where the amount of gas at station i is gas[i].You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i to
2016-05-29 23:06:40 279
原创 [leetcode] 【数组】73. Set Matrix Zeroes
Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.题意给定一个二维数组表示一个矩阵,如果某个元素为0,那么把这个元素所在行和列的所有元素置为0。不使用额外空间。题解使用额外的空间的话,就是做两个一维数组,分别标记哪一行哪一列有0,然后把这些行和
2016-05-28 11:42:42 1471
原创 [leetcode] 【数组】 89. Gray Code
The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the total number of bits in the code, print the sequence of
2016-05-28 10:59:36 284
原创 [leetcode] 【数组】70. Climbing Stairs
You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?题意 爬一个n阶楼梯,每次可以爬1-2步,问有多少种
2016-05-25 14:37:04 249
原创 [leetcode] 【数组】 66. Plus One
Given a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant digit is at the head of the list.题意用一个数组表示一个数,每
2016-05-25 14:09:03 224
原创 [leetcode] 【数组】48. Rotate Image
You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?题意用二维数组表示一张2d图片,将图片顺时针旋转90°,不使用额外空间。题解1、由外往内一
2016-05-25 13:37:02 229
原创 [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.For example, Given [0,1,0,2,1,0,1,3,2,1,2,1], ret
2016-05-22 22:14:28 338
原创 [leetcode] 【数组】36. Valid Sudoku
Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with the character ‘.’. A partially filled sudoku whic
2016-05-22 20:04:55 275
原创 [leetcode] 【数组】 60. Permutation Sequence
The set [1,2,3,…,n] contains a total of n! unique permutations.By listing and labeling all of the permutations in order, We get the following sequence (ie, for n = 3):“123” “132” “213” “231” “312”
2016-05-22 19:47:04 273
原创 [leetcode] 【数组】31. Next Permutation
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest possible orde
2016-05-22 12:28:02 245
转载 equal_range用法
equal_range是C++ STL中的一种二分查找的算法,试图在已排序的[first,last)中寻找value,它返回一对迭代器i和j,其中i是在不破坏次序的前提下,value可插入的第一个位置(亦即lower_bound),j则是在不破坏次序的前提下,value可插入的最后一个位置(亦即upper_bound),因此,[i,j)内的每个元素都等同于value,而且[i,j)是[first,
2016-05-22 03:04:51 266
原创 [leetcode] 【数组】27. Remove Element
Given an array and a value, 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 in place with constant memory.The order
2016-05-22 03:01:11 207
原创 [leetcode] 【数组】18. 4Sum
Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.Note: Elements in a quad
2016-05-22 02:44:57 517
原创 [leetcode] 【数组】16. 3Sum Closest
Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exactly
2016-05-22 02:29:01 229
原创 [leetcode] 【数组】15. 3Sum
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note: Elements in a triplet (a,b,c) must be i
2016-05-22 02:26:05 221
原创 [leetcode] 【数组】1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution. Example: Given nums = [2, 7, 1
2016-05-22 02:16:51 239
原创 [leetcode] 【数组】128. Longest Consecutive Sequence
Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example, Given [100, 4, 200, 1, 3, 2], The longest consecutive elements sequence is [1, 2, 3, 4].
2016-05-22 02:03:47 363
原创 [leetcode] 【数组】4. Median of Two Sorted Arrays
There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).题解这是一道非常经典的题。这题更通用的形式是,给定两个已经排
2016-05-22 01:44:38 299
原创 [leetcode]【数组】81. Search in Rotated Sorted Array II
Follow up for “Search in Rotated Sorted Array”: What if duplicates are allowed?Would this affect the run-time complexity? How and why?Write a function to determine if a given target is in the array.题解
2016-05-22 00:07:59 255
原创 [leetcode]【数组】33. Search in Rotated Sorted Array
Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target value to search. If found in the array return its index
2016-05-22 00:00:10 272
原创 [leetcode]【数组】80. Remove Duplicates from Sorted Array II
Follow up for “Remove Duplicates”: What if duplicates are allowed at most twice?For example, Given sorted array nums = [1,1,1,2,2,3],Your function should return length = 5, with the first five elemen
2016-05-21 23:47:02 315
原创 [leetcode]【数组】26. Remove Duplicates from Sorted Array
Given a sorted array, 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 in place with cons
2016-05-21 23:37:13 269
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人