
LeetCode
文章平均质量分 84
Cindy_niu
这个作者很懒,什么都没留下…
展开
-
[C++]LeetCode: 11 ZigZag Conversion
题目:原创 2014-11-08 20:14:42 · 646 阅读 · 0 评论 -
[C++]LeetCode: 12 Palindrome Number
题目:Determine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Some hints:Could negative integers be palindromes? (ie, -1)If you are thinking of原创 2014-11-09 10:10:20 · 585 阅读 · 0 评论 -
[C++]LeetCode: 14 Two Sum
题目:Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up to the ta原创 2014-11-10 19:51:27 · 1109 阅读 · 0 评论 -
[C++]LeetCode: 15 3Sum Closest (plus JAVA Code)
题目: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 hav原创 2014-11-11 18:34:46 · 941 阅读 · 0 评论 -
[C++]LeetCode: 13 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.原创 2014-11-09 21:56:35 · 720 阅读 · 0 评论 -
[C++]LeetCode: 16 Roman to Integer
题目:Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.w原创 2014-11-11 19:26:39 · 609 阅读 · 0 评论 -
[C++]LeetCode: 17 Reverse Integer
题目:原创 2014-11-16 11:22:46 · 527 阅读 · 0 评论 -
[C++]LeetCode: 18 Valid Number
题目:原创 2014-11-16 20:21:23 · 672 阅读 · 0 评论 -
[C++]LeetCode: 19 Partition List
题目:原创 2014-11-17 15:13:42 · 547 阅读 · 0 评论 -
[C++]LeetCode: 20 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 rea原创 2014-11-17 18:26:53 · 616 阅读 · 0 评论 -
[C++]LeetCode: 21 Longest Common Prefix
题目:原创 2014-11-18 15:29:22 · 534 阅读 · 0 评论 -
[C++]LeetCode: 23 Length of Last Word
题目:Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not exist, return 0.Note:原创 2014-11-19 17:44:29 · 636 阅读 · 0 评论 -
[C++]LeetCode: 22 Valid Parentheses
题目:原创 2014-11-18 20:10:21 · 591 阅读 · 0 评论 -
[C++]LeetCode: 24 String to Integer (atoi)
题目:Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible原创 2014-11-19 20:24:45 · 618 阅读 · 0 评论 -
[C++]LeetCode: 25 Valid Palindrome
题目:Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Panama" is a palindrome."race a c原创 2014-11-20 13:56:49 · 914 阅读 · 0 评论 -
[C++]LeetCode: 1 Remove Element
题目:Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn't matter what you leave beyond the new lengt原创 2014-11-04 19:18:23 · 687 阅读 · 0 评论 -
[C++]LeetCode: 6 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.Gi原创 2014-11-04 20:07:27 · 723 阅读 · 0 评论 -
[C++]LeetCode: 7 Pascal's Triangle
题目:Given numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]]思路:原创 2014-11-04 20:12:41 · 649 阅读 · 0 评论 -
[C++]LeetCode: 5 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.思路:Attenti原创 2014-11-04 19:59:38 · 664 阅读 · 0 评论 -
[C++]LeetCode: 4 Remove Nth Node From End of List
题目:原创 2014-11-04 19:50:16 · 614 阅读 · 0 评论 -
[C++]LeetCode: 3 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.思路:Atte原创 2014-11-04 19:43:07 · 1609 阅读 · 0 评论 -
[C++]LeetCode: 2 Remove Duplicates from Sorted Array
题目:原创 2014-11-04 19:32:54 · 834 阅读 · 0 评论 -
[C++]LeetCode: 26 Min Stack
题目:原创 2014-11-20 20:34:53 · 810 阅读 · 0 评论 -
[C++]LeetCode: 27 Implement strStr()
题目:Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.实现子字符串原创 2014-11-22 17:13:13 · 560 阅读 · 0 评论 -
[C++]LeetCode: 33 Combination Sum
题目:Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeated number may be chosen from C unlim原创 2014-11-27 19:20:51 · 641 阅读 · 0 评论 -
[C++]LeetCode: 34 Combination Sum II
题目:Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.Each number in C may only be used once in th原创 2014-11-27 20:50:29 · 751 阅读 · 0 评论 -
[C++]LeetCode: 36 Symmetric Tree
题目:Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \3 4 4 3原创 2014-11-29 15:53:47 · 571 阅读 · 0 评论 -
[C++]LeetCode: 8 Pascal's Triangle II
题目:原创 2014-11-05 21:36:13 · 534 阅读 · 0 评论 -
[C++]LeetCode: 9 Add Binary
题目:Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".思路:原创 2014-11-06 21:36:03 · 1370 阅读 · 0 评论 -
[C++]LeetCode: 28 Valid Sudoku
题目:原创 2014-11-24 14:42:19 · 602 阅读 · 0 评论 -
[C++]LeetCode: 35 Balanced Binary Tree
题目:Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node ne原创 2014-11-29 12:07:36 · 460 阅读 · 0 评论 -
[C++]LeetCode: 10 Merge Sorted Array
题目:Given two sorted integer arrays A and B, merge B into A as one sorted array.Note:You may assume that A has enough space (size that is greater or equal to m + n) to hold additional eleme原创 2014-11-07 22:02:23 · 516 阅读 · 0 评论 -
[C++]LeetCode: 30 Minimum Depth of Binary Tree
题目:Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.原创 2014-11-24 21:50:26 · 639 阅读 · 0 评论 -
[C++]LeetCode: 32 Binary Tree Level Order Traversal II
题目:Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For example:Given binary tree {3,9,20,#,原创 2014-11-25 19:39:54 · 884 阅读 · 0 评论 -
[C++]LeetCode: 29 Maximum Depth of Binary Tree
题目:原创 2014-11-24 20:15:14 · 547 阅读 · 0 评论 -
[C++]LeetCode: 31 Binary Tree Level Order Traversal
题目:Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree {3,9,20,#,#,15,7}, 3 / \ 9原创 2014-11-25 19:17:18 · 906 阅读 · 0 评论 -
[C++]LeetCode: 76 Rotate List
题目:Given a list, rotate the list to the right by k places, where k is non-negative.For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2->3->NULL.给出一个链表,和一个非负数k, 要求从链表尾节点开始原创 2015-01-07 16:59:20 · 964 阅读 · 0 评论 -
[C++]LeetCode: 37 Construct Binary Tree from Preorder and Inorder Traversal
题目:Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.Anwser 1: 递归法思路解析:这道题是树中比较有难度的题目,需要根据先序遍历和中序原创 2014-12-01 20:09:29 · 758 阅读 · 0 评论 -
[C++]LeetCode: 47 Anagrams
题目:Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.For example:Input: ["tea","and","ate","eat","den"]Output:原创 2014-12-16 19:27:13 · 761 阅读 · 0 评论 -
[C++]LeetCode: 121 Palindrome Partitioning (分割回文子串 回溯法)
题目:Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.For example, given s = "aab",Return [原创 2015-01-25 15:57:02 · 1956 阅读 · 0 评论