菱纱梦

导航

随笔分类 -  LeetCode

上一页 1 2 3 下一页

Binary Tree Level Order Traversal <leetcode>
摘要:Given a binary tree, return thelevel ordertraversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree{3,9,2... 阅读全文

posted @ 2014-09-08 21:14 菱纱梦 阅读(155) 评论(0) 推荐(0)

Spiral Matrix II <leetcode>
摘要:Given an integern, generate a square matrix filled with elements from 1 ton2in spiral order.For example,Givenn=3,You should return the following matri... 阅读全文

posted @ 2014-09-08 21:01 菱纱梦 阅读(160) 评论(0) 推荐(0)

Linked List Cycle II <leetcode>
摘要:Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull.Follow up:Can you solve it without using extra space?算法:... 阅读全文

posted @ 2014-09-08 20:29 菱纱梦 阅读(135) 评论(0) 推荐(0)

Binary Tree Postorder Traversal <leetcode>
摘要:Given a binary tree, return thepostordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[3,2,1].No... 阅读全文

posted @ 2014-09-07 14:08 菱纱梦 阅读(182) 评论(0) 推荐(0)

Best Time to Buy and Sell Stock III <leetcode>
摘要: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 @ 2014-09-07 13:21 菱纱梦 阅读(143) 评论(0) 推荐(0)

Best Time to Buy and Sell Stock <leetcode>
摘要:Say 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 阅读全文

posted @ 2014-09-07 12:26 菱纱梦 阅读(181) 评论(0) 推荐(0)

Search a 2D Matrix <leetcode>
摘要:Write an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties:Integers in each row are sorted from l... 阅读全文

posted @ 2014-09-07 10:32 菱纱梦 阅读(162) 评论(0) 推荐(0)

Minimum Path Sum <leetcode>
摘要:Given amxngrid filled with non-negative numbers, find a path from top left to bottom right whichminimizesthe sum of all numbers along its path.Note:Yo... 阅读全文

posted @ 2014-09-07 10:14 菱纱梦 阅读(164) 评论(0) 推荐(0)

Container With Most Water <leetcode>
摘要: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 @ 2014-09-06 22:36 菱纱梦 阅读(132) 评论(0) 推荐(0)

Binary Tree Level Order Traversal II <leetcode>
摘要: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 e... 阅读全文

posted @ 2014-09-03 20:48 菱纱梦 阅读(169) 评论(0) 推荐(0)

Rotate Image <leetcode>
摘要:You are given annxn2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?思路:首先左右翻转,然后按照左下,右上... 阅读全文

posted @ 2014-09-03 19:10 菱纱梦 阅读(137) 评论(0) 推荐(0)

Unique paths <leetcode>
摘要:A robot is located at the top-left corner of amxngrid (marked 'Start' in the diagram below).The robot can only move either down or right at any point ... 阅读全文

posted @ 2014-09-03 16:57 菱纱梦 阅读(138) 评论(0) 推荐(0)

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... 阅读全文

posted @ 2014-09-03 16:26 菱纱梦 阅读(241) 评论(0) 推荐(0)

Pascal's Triangle <LeetCode>
摘要:Pascal's TriangleGivennumRows, generate the firstnumRowsof Pascal's triangle.For example, givennumRows= 5,Return[ [1], [1,1], [1,2,1], [1,3,... 阅读全文

posted @ 2014-09-03 16:02 菱纱梦 阅读(139) 评论(0) 推荐(0)

Sort Colors <LeetCode>
摘要:Sort ColorsGiven an array withnobjects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the or... 阅读全文

posted @ 2014-09-03 15:58 菱纱梦 阅读(140) 评论(0) 推荐(0)

Merge Sorted Array <leetcode>
摘要: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... 阅读全文

posted @ 2014-09-03 10:42 菱纱梦 阅读(125) 评论(0) 推荐(0)

Symmetric Tree <LeetCode>
摘要: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 / \ ... 阅读全文

posted @ 2014-09-03 09:41 菱纱梦 阅读(149) 评论(0) 推荐(0)

Merge Two Sorted Lists <LeetCode>
摘要:---恢复内容开始---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 lis... 阅读全文

posted @ 2014-08-31 15:46 菱纱梦 阅读(156) 评论(0) 推荐(0)

Maximum Subarray <LeetCode>
摘要: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 @ 2014-08-31 15:04 菱纱梦 阅读(136) 评论(0) 推荐(0)

Single Number II <LeetCode>
摘要:Given an array of integers, every element appearsthreetimes except for one. Find that single one.Note:Your algorithm should have a linear runtime comp... 阅读全文

posted @ 2014-08-31 13:52 菱纱梦 阅读(133) 评论(0) 推荐(0)

上一页 1 2 3 下一页