12 2015 档案

[LeetCode]113. Maximum Depth of Binary Tree二叉树的最大深度
摘要:Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest le... 阅读全文

posted @ 2015-12-25 19:25 AprilCheny 阅读(166) 评论(0) 推荐(0)

[LeetCode]112. 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,... 阅读全文

posted @ 2015-12-16 10:20 AprilCheny 阅读(429) 评论(0) 推荐(0)

[LeetCode]111. Find Minimum in Rotated Sorted Array II旋转数组最小值II
摘要:Follow upfor "Find Minimum in Rotated Sorted Array":What ifduplicatesare allowed?Would this affect the run-time complexity? How and why?Suppose a sort... 阅读全文

posted @ 2015-12-15 11:02 AprilCheny 阅读(163) 评论(0) 推荐(0)

[LeetCode]110. Find Minimum 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 7might become4 5 6 7 0 1 2).Find the minimum element.You m... 阅读全文

posted @ 2015-12-15 09:33 AprilCheny 阅读(1024) 评论(0) 推荐(0)

[LeetCode]109. Construct Binary Tree from Inorder and Postorder Traversal由中序序列和后序序列重建二叉树
摘要:Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.解法:这题和由前序序列和中序... 阅读全文

posted @ 2015-12-14 18:43 AprilCheny 阅读(381) 评论(0) 推荐(0)

[LeetCode]108. 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.解法:前序遍历的第一个元素为树... 阅读全文

posted @ 2015-12-14 18:38 AprilCheny 阅读(530) 评论(0) 推荐(0)

[LeetCode]107. Best Time to Buy and Sell Stock III股票买卖III
摘要:Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete a... 阅读全文

posted @ 2015-12-11 20:14 AprilCheny 阅读(187) 评论(0) 推荐(0)

[LeetCode]105. 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 "adjace... 阅读全文

posted @ 2015-12-11 11:31 AprilCheny 阅读(240) 评论(0) 推荐(0)

[LeetCode]104. Basic Calculator II基本计算器
摘要:Implement a basic calculator to evaluate a simple expression string.The expression string contains onlynon-negativeintegers,+,-,*,/operators and empty... 阅读全文

posted @ 2015-12-09 15:16 AprilCheny 阅读(190) 评论(0) 推荐(0)

[LeetCode]103. Find the Duplicate Number重复值查找
摘要:Given an arraynumscontainingn+ 1 integers where each integer is between 1 andn(inclusive), prove that at least one duplicate number must exist. Assume... 阅读全文

posted @ 2015-12-09 11:21 AprilCheny 阅读(201) 评论(0) 推荐(0)

[LeetCode]102. Product of Array Except Self数组乘积
摘要:Given an array ofnintegers wheren> 1,nums, return an arrayoutputsuch thatoutput[i]is equal to the product of all the elements ofnumsexceptnums[i].Solv... 阅读全文

posted @ 2015-12-09 09:18 AprilCheny 阅读(172) 评论(0) 推荐(0)

[LeetCode]101. Trapping Rain Water收集雨水
摘要:Givennnon-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.Fo... 阅读全文

posted @ 2015-12-08 19:56 AprilCheny 阅读(293) 评论(0) 推荐(0)

[LeetCode]100. Remove Duplicates from Sorted Array II排序数组去重
摘要:Follow up for "Remove Duplicates":What if duplicates are allowed at mosttwice?For example,Given sorted arraynums=[1,1,1,2,2,3],Your function should re... 阅读全文

posted @ 2015-12-08 19:05 AprilCheny 阅读(170) 评论(0) 推荐(0)

[LeetCode]99. Container with Most Water最大容积
摘要:Givennnon-negative integersa1,a2, ...,an, where each represents a point at coordinate (i,ai).nvertical lines are drawn such that the two endpoints of ... 阅读全文

posted @ 2015-12-05 11:35 AprilCheny 阅读(173) 评论(0) 推荐(0)

[LeetCode]98. SortColors颜色排序
摘要:Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, ... 阅读全文

posted @ 2015-12-04 20:53 AprilCheny 阅读(282) 评论(0) 推荐(0)

[LeetCode]97. Reorder List链表重排序
摘要:Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For ... 阅读全文

posted @ 2015-12-04 10:10 AprilCheny 阅读(153) 评论(0) 推荐(0)