LeetCode
文章平均质量分 75
哎-哭泣的鱼
这个作者很懒,什么都没留下…
展开
-
【LeetCode】Letter Combinations of a Phone Number
Letter Combinations of a Phone Number Total Accepted: 4387 Total Submissions: 17627 My SubmissionsGiven a digit string, return all possible letter combinations that the number could represent.A ma原创 2014-01-25 16:11:44 · 2466 阅读 · 0 评论 -
【LeetCode】Candy
Candy Total Accepted: 4149 Total Submissions: 26052 My SubmissionsThere are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected原创 2013-12-30 13:11:54 · 884 阅读 · 0 评论 -
【LeetCode】Longest Consecutive Sequence
Longest Consecutive Sequence Total Accepted: 4076 Total Submissions: 15654 My SubmissionsGiven an unsorted array of integers, find the length of the longest consecutive elements sequence.For examp原创 2014-01-02 13:16:25 · 675 阅读 · 0 评论 -
【LeetCode】Valid Parentheses && Generate Parentheses && Longest Valid Parentheses
这三道题都是括号匹配问题。1、Valid Parentheses Total Accepted: 5225 Total Submissions: 18918 My SubmissionsGiven a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input s原创 2014-01-24 10:46:15 · 1268 阅读 · 0 评论 -
【LeetCode】Reverse Integer
Reverse Integer Total Accepted: 6363 Total Submissions: 15698 My SubmissionsReverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321恩,习惯上,用/求除数,用%求余数。我比较擅长用字原创 2013-12-30 13:32:00 · 652 阅读 · 0 评论 -
【LeetCode】Word Ladder
Word Ladder Total Accepted: 3388 Total Submissions: 21998 My SubmissionsGiven two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such原创 2013-12-31 14:21:16 · 1082 阅读 · 0 评论 -
【LeetCode】Longest Common Prefix
Longest Common Prefix Total Accepted: 4226 Total Submissions: 15745 My SubmissionsWrite a function to find the longest common prefix string amongst an array of strings.最直接的办法就是循环数组,依次迭代求最长前缀。不过这样会原创 2014-01-07 09:08:53 · 724 阅读 · 0 评论 -
【LeetCode】Valid Palindrome
Valid Palindrome Total Accepted: 4526 Total Submissions: 21149 My SubmissionsGiven a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For exampl原创 2014-01-07 23:05:43 · 740 阅读 · 0 评论 -
【LeetCode】Palindrome Partitioning
Palindrome Partitioning Total Accepted: 4268 Total Submissions: 17532 My SubmissionsGiven a string s, partition s such that every substring of the partition is a palindrome.Return all possible pal原创 2014-01-14 14:21:50 · 1954 阅读 · 5 评论 -
【LeetCode】Search a 2D Matrix && 【九度】题目1384:二维数组中的查找
Search a 2D Matrix Total Accepted: 4984 Total Submissions: 16715 My SubmissionsWrite an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:I原创 2014-01-22 10:12:57 · 1226 阅读 · 0 评论 -
【LeetCode】First Missing Positive
First Missing Positive Total Accepted: 3893 Total Submissions: 18419 My SubmissionsGiven an unsorted integer array, find the first missing positive integer.For example,Given [1,2,0] return 3,a原创 2014-01-09 22:53:21 · 750 阅读 · 0 评论 -
【LeetCode】Longest Palindromic Substring && 【九度】题目1528:最长回文子串(腾讯2013年实习生招聘二面面试题)
Longest Palindromic Substring Total Accepted: 4808 Total Submissions: 23151 My SubmissionsGiven a string S, find the longest palindromic substring in S. You may assume that the maximum length of S i原创 2014-01-12 22:41:55 · 943 阅读 · 0 评论 -
【LeetCode】Remove Duplicates from Sorted Array I && II
I、每个数据只允许出现1次Remove Duplicates from Sorted Array Total Accepted: 7116 Total Submissions: 21546 My SubmissionsGiven a sorted array, remove the duplicates in place such that each element appear only原创 2014-01-22 16:13:09 · 1063 阅读 · 0 评论 -
【LeetCode】Remove Duplicates from Sorted List I && II
I、每个数据只允许出现1次Remove Duplicates from Sorted List Total Accepted: 7120 Total Submissions: 20880 My SubmissionsGiven a sorted linked list, delete all duplicates such that each element appear only onc原创 2014-01-22 16:26:04 · 892 阅读 · 0 评论 -
【LeetCode】Two Sum
Two Sum Total Accepted: 7616 Total Submissions: 34943 My SubmissionsGiven an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return原创 2013-12-29 21:43:22 · 774 阅读 · 0 评论 -
【LeetCode】Trapping Rain Water
Trapping Rain Water Total Accepted: 8428 Total Submissions: 30087 My SubmissionsGiven n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water原创 2014-05-07 12:20:08 · 675 阅读 · 0 评论 -
【LeetCode】Binary Tree Preorder Traversal 二叉树前序遍历递归以及非递归算法
Binary Tree Preorder Traversal Total Accepted: 17403 Total Submissions: 50093 My SubmissionsGiven a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tre原创 2014-05-07 17:14:12 · 782 阅读 · 0 评论 -
【LeetCode】Count and Say
Count and Say Total Accepted: 7984 Total Submissions: 30169 My SubmissionsThe count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1 is read off原创 2014-05-06 14:43:56 · 1802 阅读 · 0 评论 -
【LeetCode】Gas Station
Gas Station Total Accepted: 10350 Total Submissions: 43091 My SubmissionsThere 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 un原创 2014-04-25 17:44:38 · 618 阅读 · 0 评论 -
【LeetCode】Restore IP Addresses
Restore IP Addresses Total Accepted: 6682 Total Submissions: 33461 My SubmissionsGiven a string containing only digits, restore it by returning all possible valid IP address combinations.For exa原创 2014-04-12 22:03:59 · 753 阅读 · 0 评论 -
【LeetCode】Balanced Binary Tree
Balanced Binary Tree Total Accepted: 10515 Total Submissions: 33226 My SubmissionsGiven a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defin原创 2014-03-24 16:41:31 · 731 阅读 · 0 评论 -
【LeetCode】Same Tree
Same Tree Total Accepted: 8888 Total Submissions: 20908 My SubmissionsGiven two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are s原创 2014-02-10 13:48:04 · 1215 阅读 · 0 评论 -
【LeetCode】Binary Tree Level Order Traversal II
Binary Tree Level Order Traversal II Total Accepted: 4229 Total Submissions: 13624 My SubmissionsGiven a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left原创 2014-01-12 22:27:41 · 896 阅读 · 0 评论 -
【LeetCode】Remove Nth Node From End of List && 【九度】题目1517:链表中倒数第k个结点
Remove Nth Node From End of ListTotal Accepted: 8400 Total Submissions: 28316Given a linked list, remove the nth node from the end of list and return its head.For example,Given linked list: 1-原创 2014-03-07 10:55:46 · 1144 阅读 · 0 评论 -
【LeetCode】Evaluate Reverse Polish Notation
Evaluate Reverse Polish Notation Total Accepted: 11741 Total Submissions: 60315 My SubmissionsEvaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -,原创 2014-05-06 17:46:00 · 689 阅读 · 0 评论 -
【LeetCode】Word Ladder
Word Ladder Total Accepted: 9317 Total Submissions: 53652 My SubmissionsGiven two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, su原创 2014-05-05 13:28:44 · 779 阅读 · 0 评论 -
【LeetCode】Binary Tree Level Order Traversal
Binary Tree Level Order Traversal Total Accepted: 5091 Total Submissions: 16977 My SubmissionsGiven a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, lev原创 2014-01-10 13:26:34 · 958 阅读 · 0 评论 -
【LeetCode】Binary Tree Postorder Traversal 二叉树后序遍历递归以及非递归算法
Binary Tree Postorder Traversal Total Accepted: 15614 Total Submissions: 50928 My SubmissionsGiven a binary tree, return the postorder traversal of its nodes' values.For example:Given binary t原创 2014-05-07 18:31:28 · 1387 阅读 · 0 评论 -
【LeetCode】Recover Binary Search Tree
Recover Binary Search Tree Total Accepted: 7163 Total Submissions: 31922 My SubmissionsTwo elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its str原创 2014-04-10 12:19:53 · 1170 阅读 · 0 评论 -
【LeetCode】Populating Next Right Pointers in Each Node I & II
Populating Next Right Pointers in Each Node Total Accepted: 6122 Total Submissions: 17900 My SubmissionsGiven a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode原创 2014-01-16 13:24:35 · 962 阅读 · 0 评论 -
【LeetCode】Path Sum II
Path Sum II Total Accepted: 4441 Total Submissions: 16502 My SubmissionsGiven a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given th原创 2014-01-08 15:42:41 · 1364 阅读 · 0 评论 -
【LeetCode】Path Sum
Path Sum Total Accepted: 5082 Total Submissions: 17224 My SubmissionsGiven a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path eq原创 2014-01-08 14:10:19 · 1054 阅读 · 0 评论 -
【LeetCode】Sum Root to Leaf Numbers
Sum Root to Leaf Numbers Total Accepted: 4893 Total Submissions: 17365 My SubmissionsGiven a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example原创 2014-01-08 00:02:59 · 728 阅读 · 0 评论 -
【LeetCode】Binary Tree Inorder Traversal 二叉树中序遍历递归以及非递归算法
Binary Tree Inorder Traversal Total Accepted: 16494 Total Submissions: 47494Given a binary tree, return the inorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3},原创 2014-05-07 18:21:16 · 1327 阅读 · 0 评论 -
【LeetCode】Substring with Concatenation of All Words
Substring with Concatenation of All Words Total Accepted: 6263 Total Submissions: 35962 My SubmissionsYou are given a string, S, and a list of words, L, that are all of the same length. Find all s原创 2014-04-30 15:29:28 · 4739 阅读 · 0 评论 -
【LeetCode】Symmetric Tree
Symmetric Tree Total Accepted: 8236 Total Submissions: 25682 My SubmissionsGiven a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tr原创 2014-02-12 13:12:45 · 770 阅读 · 0 评论 -
【LeetCode】Sqrt(x)
Sqrt(x) Total Accepted: 11664 Total Submissions: 54437 My SubmissionsImplement int sqrt(int x).Compute and return the square root of x.解法1:调用Java API,Math.sqrt()。这个方法的底层实现是native。Java AC原创 2014-04-17 19:48:26 · 1280 阅读 · 0 评论 -
【LeetCode】Plus One && 【九度】题目1198:a+b
Plus One Total Accepted: 4206 Total Submissions: 14127 My SubmissionsGiven a number represented as an array of digits, plus one to the number.题目意思为给定一个数组,这个数组内的数代表某个大数,也就是可能为100位甚至多少位的一个数。例如1234原创 2014-01-03 13:56:10 · 1868 阅读 · 0 评论 -
【LeetCode】Anagrams
Anagrams Total Accepted: 7632 Total Submissions: 33683 My SubmissionsGiven an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.举例说明题目大意:原创 2014-04-18 23:10:59 · 928 阅读 · 0 评论 -
【LeetCode】Word Search
Word Search Total Accepted: 7113 Total Submissions: 36905 My SubmissionsGiven a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially原创 2014-04-15 19:47:50 · 1905 阅读 · 0 评论