自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(27)
  • 收藏
  • 关注

原创 将博客搬至CSDN

把LeetCode Solution搬到博客园啦~~欢迎小伙伴有空来坐坐。博客园地址

2015-12-31 14:36:17 325

原创 [LeetCode]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

2015-12-30 15:17:23 356

原创 [LeetCode]Distinct Subsequences

Given a string S and a string T, count the number of distinct subsequences of T in S.A subsequence of a string is a new string which is formed from the original string by deleting some (can be non

2015-12-30 13:49:11 452

原创 [LeetCode]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,#,#,15,7},

2015-12-29 16:33:37 329

原创 [LeetCode]Construct Binary Tree from Inorder and Postorder Traversal

Given inorder and postorder traversal of a tree, construct the binary tree.递归实现/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * Tree

2015-12-29 15:49:05 324

原创 [LeetCode]Construct Binary Tree from Preorder and Inorder Traversal

Given preorder and inorder traversal of a tree, construct the binary tree.由树的前序遍历和中序遍历来构建子树。首先找到根节点,然后递归找到左侧和右侧根节点完成。/** * Definition for a binary tree node. * struct TreeNode { * int val

2015-12-29 15:29:07 390

原创 [LeetCode]Binary Tree Zigzag Level Order Traversal

Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between).For example:Given binary

2015-12-26 17:15:28 274

原创 [LeetCode]Interleaving String

Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.For example,Given:s1 = "aabcc",s2 = "dbbca",When s3 = "aadbbcbcac", return true.When s3 = "aadbbbaccc", r

2015-12-26 14:29:19 272

原创 [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

2015-12-26 14:19:51 344

原创 [LeetCode]Remove Duplicates from Sorted Array II

Follow up for "Remove Duplicates":What if duplicates are allowed at most twice?For example,Given sorted array nums = [1,1,1,2,2,3],Your function should return length = 5, with the first fi

2015-12-19 20:47:47 352

原创 [LeetCode]Text Justification

Given an array of words and a length L, format the text such that each line has exactly L characters and is fully (left and right) justified.You should pack your words in a greedy approach; that i

2015-12-18 20:30:38 384

原创 [LeetCode]Valid Number

Validate if a given string is numeric.Some examples:"0" => true" 0.1 " => true"abc" => false"1 a" => false"2e10" => trueNote: It is intended for the problem statement to be ambiguo

2015-12-17 16:27:15 413

原创 [LeetCode]Find Median from Data Stream

Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two middle value.Examples: [2,3,4] , the median

2015-12-17 13:55:04 327

原创 [LeetCode]Recover Binary Search Tree

Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.找到平衡二叉树的错误节点。对平衡二叉树,中序遍历就是其节点排序。所以采用中序遍历的方法记录前一个节点,判断是否有序。特别注意如果只有

2015-12-17 13:33:57 221

原创 [LeetCode]Pascal's Triangle II

Given an index k, return the kth row of the Pascal's triangle.For example, given k = 3,Return [1,3,3,1].Note:Could you optimize your algorithm to use only O(k) extra space?class Soluti

2015-12-16 15:08:54 289

原创 [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], [

2015-12-16 10:53:08 340

原创 [LeetCode]Unique Binary Search Trees II

Given n, generate all structurally unique BST's (binary search trees) that store values 1...n.For example,Given n = 3, your program should return all 5 unique BST's shown below. 1 3

2015-12-15 16:49:23 256

原创 [LeetCode]Course Schedule II

There are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as

2015-12-15 13:00:49 271

原创 [LeetCode]Course Schedule

Course ScheduleThere are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1,

2015-12-15 12:28:51 268

原创 [LeetCode]Restore IP Addresses

Given a string containing only digits, restore it by returning all possible valid IP address combinations.For example:Given "25525511135",return ["255.255.11.135", "255.255.111.35"]. (Order

2015-12-14 22:57:24 328

原创 [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 o

2015-12-12 21:00:17 284

原创 [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.在一个M * N的矩阵中,所有的元素只有0和1, 找出只包含1的最大矩形。例如:图中是一个4 × 6的矩形,画出红色的是我们要找到的区域。

2015-12-12 20:55:04 240

原创 [LeetCode]Game of Life

According to the Wikipedia's article: "The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970."Given a board with m 

2015-12-06 21:15:23 608

原创 [LEetCode]Best Time to Buy and Sell Stock with Cooldown

Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy on

2015-12-06 17:18:35 582

原创 [LeetCode]Minimum Height Trees

For a undirected graph with tree characteristics, we can choose any node as the root. The result graph is then a rooted tree. Among all possible rooted trees, those with minimum height are called mini

2015-12-05 22:37:37 799

原创 [LeetCode]Super Ugly Number

Write a program to find the nth super ugly number.Super ugly numbers are positive numbers whose all prime factors are in the given prime list primes of size k. For example, [1, 2, 4, 7, 8, 13,

2015-12-04 17:33:42 2530

原创 [LeetCode]Burst Balloons

Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by array nums. You are asked to burst all the balloons. If the you burst balloon i you will get num

2015-12-04 15:32:26 845

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除