- 博客(10)
- 收藏
- 关注
原创 Implement strStr()
Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.#include#includeusing namespace std;int strStr(string haystack, string need
2017-06-11 17:20:12
210
原创 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.
2017-04-23 16:41:05
222
原创 Valid Parentheses
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}" are all va
2017-04-23 16:17:38
203
原创 Count and Say
The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1 is read off as "one 1" or 11.11 is read off as "two 1s" or 21.21 is read off as
2017-04-23 15:35:43
197
原创 Search Insert Position
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the array.
2017-04-04 19:04:29
188
原创 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
2017-04-04 18:31:33
236
原创 Merge Two Sorted Lists
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.将两个已排好序的链表合并,每次比较两个链表首位的大小,将较小的一位放入新的链表中,并在原链表中去掉首位,依次比
2017-03-20 18:52:13
209
原创 Maximum Subarray
Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [-2,1,-3,4,-1,2,1,-5,4],the contiguous subarray [4,-1,2,1]
2017-03-13 20:03:34
297
原创 Search a 2D Matrix IIWrite an efficient algorithm that searches for a value in an m x n matrix. This
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted in ascending from left to right.Integers in
2017-03-06 15:21:45
650
原创 Reverse digits of an integer.
Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321click to show spoilers.Note:The input is assumed to be a 32-bit signed integer. Your function
2017-02-26 19:59:46
290
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人