- 博客(25)
- 收藏
- 关注
原创 leetcode-543. Diameter of Binary Tree
leetcode-543. Diameter of Binary TreeGiven a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nod
2017-03-24 13:57:47 219
原创 leetcode-242. Valid Anagram
leetcode-242. Valid AnagramGiven two strings s and t, write a function to determine if t is an anagram of s.For example,s = "anagram", t = "nagaram", return true.s = "rat", t = "car", return false.解法
2017-03-24 13:56:26 169
原创 leetcode-141. Linked List Cycle
leetcode-141. Linked List CycleGiven a linked list, determine if it has a cycle in it.class Solution {public: bool hasCycle(ListNode *head) { // if(!head || !head->next || !head -> next ->
2017-03-20 19:49:53 162
原创 leetcode-121. Best Time to Buy and Sell Stock
leetcode-121. Best Time to Buy and Sell StockSay you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, b
2017-03-17 14:13:23 286
原创 leetcode-53. Maximum Subarray
leetcode-53. Maximum SubarrayFind 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
2017-03-16 23:05:20 202
原创 leetcode-219. Contains Duplicate II
leetcode-219. Contains Duplicate IIGiven an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the absolute differe
2017-03-16 16:46:20 250
原创 leetcode-217. Contains Duplicate
leetcode-217. Contains DuplicateGiven an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should r
2017-03-16 15:58:24 208
原创 leetcode-21. Merge Two Sorted Lists
leetcode-21. Merge Two Sorted ListsMerge 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.Subscribe to see which co
2017-03-15 17:45:42 179
原创 leetcode-88. Merge Sorted Array
leetcode-88. Merge Sorted ArrayGiven two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:You may assume that nums1 has enough space (size that is greater or equa
2017-03-15 17:31:55 141
原创 leetcode-35. Search Insert Position
leetcode-35. Search Insert PositionGiven 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 assu
2017-03-08 22:22:24 157
原创 leetcode-26. Remove Duplicates from Sorted Array 78.84%
leetcode-26. Remove Duplicates from Sorted Array 78.84%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 spac
2017-03-08 21:31:46 172
原创 leetcode-20. Valid Parentheses
leetcode-20. Valid ParenthesesGiven a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" an
2017-03-08 17:00:31 165
原创 leetcode-11. Container With Most Water
leetcode-11. Container With Most WaterGiven 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
2017-03-08 16:19:24 396
原创 leetcode-17. Letter Combinations of a Phone Number
leetcode-17. Letter Combinations of a Phone NumberGiven a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone
2017-03-08 14:22:17 174
原创 leetcode-14. Longest Common Prefix
leetcode-14. Longest Common PrefixWrite a function to find the longest common prefix string amongst an array of strings.最长的子序列一定是一个序列的子集,不可能比这个array中任何一个string要长class Solution {public: string long
2017-03-08 11:28:56 150
原创 leetcode-66. Plus One
leetcode-66. Plus OneGiven a non-negative integer represented as a non-empty array of digits, plus one to the integer.You may assume the integer do not contain any leading zero, except the number 0 it
2017-03-08 11:00:38 386
原创 leetcode-9. Palindrome Number
leetcode-9. Palindrome NumberDetermine whether an integer is a palindrome. Do this without extra space.class Solution {public: bool isPalindrome(int x) { if(x < 0) return false
2017-03-07 23:45:16 268
原创 leetcode-27. Remove Element
leetcod-27. Remove ElementGiven 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 wit
2017-03-07 23:16:43 170
原创 leetcode-208. Implement Trie (Prefix Tree)
leetcode-208. Implement Trie (Prefix Tree)Implement a trie with insert, search, and startsWith methods.Note:You may assume that all inputs are consist of lowercase letters a-z.class TrieNode{public:
2017-03-07 16:55:09 180
原创 leetcode-7. Reverse Integer
leetcode - 7. Reverse IntegerReverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321class Solution {public: int reverse(int x) { long long res = 0;
2017-03-07 13:04:08 347
原创 leetcode-12. Integer to Roman
leetcode-12. Integer to RomanGiven an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.Subscribe to see which companies asked this question.class Solut
2017-03-04 18:17:40 155
原创 leetcode-13. Roman to Integer
LeetCode-12. Integer to RomanGiven a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.Subscribe to see which companies asked this question.class Solut
2017-03-04 17:37:00 156
原创 leetcode-15.Three Sum
leetcode -15.Three SumGiven 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: The solution set m
2017-03-04 14:55:02 212
原创 leetcode-1.Two Sum
leetcode -1.Two Sum解法1 vector::push_back—Add element at the end 把新的元素加在最后 vector::pop_back—Delete last element (public member function) 把最后的元素删除 vector::insert—Insert elements (public member
2017-03-03 22:17:19 199
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人