
LeetCode
文章平均质量分 76
石头_奋斗
这个作者很懒,什么都没留下…
展开
-
LeetCode_Simplify Path
Given an absolute path for a file (Unix-style), simplify it.For example,path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c"click to show corner cases.Corner Cases:Did you co原创 2014-10-04 19:23:45 · 628 阅读 · 0 评论 -
LeetCode_Single Number&Single NumberII
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 usi原创 2014-05-11 19:33:14 · 643 阅读 · 0 评论 -
[LeetCode]二叉树题目总结
【LeetCode】二叉树习题个人总结近一个月来,刷了不少LeetCode题目。但是总还是感觉提高的不多,自己最初想的一边做一边总结的初衷也没有正常执行,今晚静下心来,总结一下和二叉树有关的题目。基础题目:【二叉树遍历】Binary Tree Postorder TraversalBinary Tree Preorder TraversalBinary Tree Inord原创 2014-06-19 20:30:58 · 5203 阅读 · 1 评论 -
LeetCode_将LeetCode中的字符串用例转换成二叉树
最近刷LeetCode题目时总会出现错误时,手动生成用例的情况,于是自己写了一个将原创 2014-06-22 15:02:14 · 2519 阅读 · 0 评论 -
LeetCode_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.原创 2014-05-03 16:59:42 · 1051 阅读 · 0 评论 -
LeetCode_Reverse Words in a String
Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".click to show clarification.Clarification:What constitutes原创 2014-05-03 17:38:48 · 998 阅读 · 0 评论 -
Max Points on a Line
Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.题目只有一句话,原创 2014-05-05 07:19:44 · 706 阅读 · 0 评论 -
LeetCode_Insertion Sort List
Sort a linked list using insertion sort.原创 2014-05-06 20:48:55 · 726 阅读 · 0 评论 -
LeetCode_Triangle
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2], [3,4], [原创 2014-06-23 20:55:33 · 682 阅读 · 0 评论 -
LeetCode_Scramble String
Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representation of s1 = "great": great / \ gr原创 2014-06-25 20:43:46 · 845 阅读 · 0 评论 -
LeetCode_Word Break
之前好像是写过这个题目的解题报告,说是原创 2014-07-06 19:55:14 · 725 阅读 · 0 评论 -
LeetCode_Lined List CycleII
Given a linked list, return the node where the cycle begins. If there is no cycle, return null.Follow up:Can you solve it without using extra space?这道题让我很无语,原创 2014-05-11 15:02:44 · 583 阅读 · 0 评论 -
LeetCode_Add Binary
Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".这个题目比较简单,最初我还想是否需要考虑a,b中出现正负符号的问题,对于OJ的judge是不要求考虑的。这样一来问题就变得简单了,保证两个数相加从低位到高位进行原创 2014-09-19 15:10:58 · 559 阅读 · 0 评论 -
LeetCode_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原创 2014-10-04 18:16:56 · 593 阅读 · 0 评论 -
LeetCode_Largest Rectangle in Histogram
Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram.Above is a histogram where width of ea原创 2014-09-30 16:40:53 · 766 阅读 · 0 评论 -
LeetCode_Reverse Nodes in k-Group
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is.原创 2014-09-19 14:26:11 · 749 阅读 · 0 评论 -
LeetCode_Minimun Path Sum
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.Note: You can only move either down or right at原创 2014-08-09 10:12:19 · 718 阅读 · 0 评论 -
LeetCode_Binary Tree Preorder Traversal
Given a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3},1\2/3return [1,2,3].Note: Recursive solution is trivial, could you原创 2014-05-11 14:38:28 · 556 阅读 · 0 评论 -
LeetCode_Lowest Common Ancestor
题目:给出一颗二叉树中的节点n1和n2,要求原创 2014-06-22 14:58:28 · 2819 阅读 · 0 评论 -
LeeCode_Populating Next Right Pointers in Each Node II
Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would your previous solution still work?Note:You may only use constant extr原创 2014-06-22 20:41:23 · 612 阅读 · 0 评论 -
LeetCode_Word Break II
在Word Break第一问的基础上,我们首先确定了在原创 2014-07-06 21:41:32 · 821 阅读 · 0 评论 -
LeetCode_Reverse Integer
Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321click to show spoilers.Have you thought about this?Here are some good questions to ask before c原创 2014-08-08 17:03:03 · 666 阅读 · 0 评论 -
LeetCode_Maximal Rectangle
Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.原创 2014-09-30 17:02:29 · 753 阅读 · 0 评论 -
LeetCode_Subsets II
Given a collection of integers that might contain duplicates, S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not contain duplica原创 2014-08-05 10:56:11 · 827 阅读 · 0 评论 -
LeetCode_Flatten Binary Tree to Linked List
Flatten Binary Tree to Linked List原创 2014-06-19 20:55:10 · 654 阅读 · 0 评论 -
LeetCode_Path Sum
Given 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 equals the given sum.For example:Given the below binary tree and sum原创 2014-06-23 20:40:29 · 629 阅读 · 0 评论 -
LeetCode_Evaluate Reverse Polish Notation
Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be an integer or another expression.Some examples:["2", "1", "+", "原创 2014-05-05 06:34:48 · 643 阅读 · 0 评论 -
LeetCode_Sort List
Sort a linked list in O(n log n) time using constant space complexity.原创 2014-05-06 20:44:10 · 1397 阅读 · 0 评论 -
LeetCode_Clone Graph
Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.OJ's undirected graph serialization:Nodes are labeled uniquely.We use # as a separator for each原创 2014-06-23 21:06:49 · 823 阅读 · 0 评论 -
LeetCode_Pow_x_n
Implement pow(x, n).题目很简单,就是实现x的n村原创 2014-07-06 21:58:00 · 799 阅读 · 0 评论 -
LeetCode_Subsets
Given a set of distinct integers, S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not contain duplicate subsets.For example,原创 2014-08-04 13:44:31 · 692 阅读 · 0 评论 -
Find Minimum in Rotated Sorted Array && Find Minimum in Rotated Sorted Array II
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).Find the minimum element.You may assume no duplicate exists in原创 2014-11-08 16:30:38 · 2501 阅读 · 0 评论 -
LeetCode_First Missing Positive
Given an unsorted integer array, find the first missing positive integer.For example,Given [1,2,0] return 3,and [3,4,-1,1] return 2.Your algorithm should run in O(n) time and uses constant spa原创 2014-10-06 18:06:59 · 712 阅读 · 0 评论 -
LeetCode_Combination Sum II
Given a collection of candidate numbers (C) and a target number (T), find all unique combinations inC where the candidate numbers sums to T.Each number in C may only be used once in the combinatio原创 2014-10-06 16:42:49 · 638 阅读 · 0 评论 -
LeetCode_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原创 2014-05-11 19:37:09 · 555 阅读 · 0 评论 -
LeetCode_Copy List with Random Pointer
A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep copy of the list.原创 2014-05-11 19:29:37 · 1287 阅读 · 0 评论 -
LeetCode_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./** * Definition for singly-link原创 2014-08-05 18:39:41 · 601 阅读 · 0 评论 -
LeetCode_Path Sum II
Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given the below binary tree and sum = 22, 5 / \原创 2014-06-23 20:45:29 · 774 阅读 · 0 评论 -
LeetCode _interleaving string
题目这里就不再站原创 2014-07-05 21:29:11 · 594 阅读 · 0 评论 -
LeetCode_Word Search
Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically原创 2014-08-08 11:48:47 · 747 阅读 · 0 评论