自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 [LeetCode][Java] Palindrome Partitioning II

题目:Given a string s, partition s such that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning of s.For example, given s = "aab"

2015-07-31 23:05:04 619

原创 [LeetCode][Java] Palindrome Partitioning

题目:Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.For example, given s = "aab",Return [

2015-07-31 22:24:00 812

原创 [LeetCode][Java] Surrounded Regions

题目:Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'.A region is captured by flipping all 'O's into 'X's in that surrounded region.For example,X X X

2015-07-29 20:55:25 825

原创 [LeetCode][Java] Sum Root to Leaf Numbers

题目:Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example is the root-to-leaf path 1->2->3 which represents the number 123.Find t

2015-07-29 17:51:59 582

原创 [LeetCode][Java] Longest Consecutive Sequence

题目:Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given [100, 4, 200, 1, 3, 2],The longest consecutive elements sequence is

2015-07-29 17:05:52 735

原创 [LeetCode][Java] Word Ladder II

题目:Given two words (start and end), and a dictionary, find all shortest transformation sequence(s) from start to end, such that:Only one letter can be changed at a timeEach intermediate word

2015-07-28 16:16:51 635

原创 [LeetCode][Java] Word Ladder

题目:Given two words (beginWord and endWord), and a dictionary, find the length of shortest transformation sequence from beginWord to endWord, such that:Only one letter can be changed at a t

2015-07-28 15:43:46 921

原创 [LeetCode][Java] Valid Palindrome

题目:Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Panama" is a palindrome."race a car" 

2015-07-28 15:11:05 762

原创 [LeetCode][Java] Binary Tree Maximum Path Sum

题目:Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the below binary tree, 1 / \ 2 3Ret

2015-07-26 22:02:34 860

原创 [LeetCOde][Java] Best Time to Buy and Sell Stock III

题目: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 at most two transactions.Note:

2015-07-26 14:08:36 840

原创 [LeetCode][Java] Best Time to Buy and Sell Stock IV

题目: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 at most k transactions.Note:Y

2015-07-26 14:03:21 1035

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

2015-07-25 00:32:36 634

原创 [LeetCode][Java] 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].题意:给定序号 k,返回杨辉三角中的第k行。比如,给定k = 3,返回[1,3,3,1].算法分析:与题目《Pascal's Triang

2015-07-24 14:50:55 486

原创 [LeetCode][Java] Pascal's Triangle

题目:Given numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]]题意:题意很明确了,就是生成杨辉三

2015-07-24 14:39:29 557

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

2015-07-24 13:15:12 949

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

2015-07-24 10:40:15 943

原创 [LeetCode][Java] Flatten Binary Tree to Linked List

题目:Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened tree should look like:

2015-07-21 11:38:44 765

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

2015-07-21 10:48:23 771

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

2015-07-21 10:16:17 634

原创 [LeetCode][Java] Minimum Depth of Binary Tree

题目:Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.题意:给定一棵二叉树,返回它的最小高度。最小高

2015-07-21 09:56:41 723

原创 [LeetCode][Java] Convert Sorted List to Binary Search Tree

题目:Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.题意:给定一个单链表,其中元素按照降序的顺序排列,将其转化为高度平衡的二叉搜索树树。算法分析:  * 利用算法Convert Sorted Array

2015-07-21 09:48:00 618

原创 [LeetCode][Java] 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.题意:给定一棵二叉树的中序和后序遍历,构建这颗二叉树。注意:你可以假定二叉树中不存

2015-07-20 21:23:05 1089

原创 [LeetCode][Java] 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.题意:给定一棵树的先序和中序遍历,构建这颗二叉树。注意:你可以假定这棵树中不存在重复

2015-07-20 21:14:51 671

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

2015-07-20 20:56:39 556

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

2015-07-20 20:39:20 875

原创 [LeetCode][Java] Binary Tree Level Order Traversal

题目:Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree {3,9,20,#,#,15,7}, 3 / \ 9

2015-07-20 20:22:28 756

原创 [LeetCode][Java] Symmetric Tree

题目: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 / \ 2 2 / \ / \3 4 4 3

2015-07-20 20:08:41 664

原创 [LeetCode][Java] Recover Binary Search Tree

题目:Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A solution using O(n) space is pretty straight forward. Could

2015-07-20 18:22:59 548

原创 [LeetCode][Java] Validate Binary Search Tree

题目:Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with keys less than the node

2015-07-20 18:10:19 671

原创 [LeetCode][Java] 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 = "aadbbba

2015-07-20 17:38:42 652

原创 [LeetCode][Java] Decode Ways

题目:A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message containing digits, determine the t

2015-07-20 12:24:21 807

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

2015-07-20 11:42:20 575

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

2015-07-20 10:29:18 604

原创 [LeetCode][Java] Reverse Linked List II

题目:Reverse a linked list from position m to n. Do it in-place and in one-pass.For example:Given 1->2->3->4->5->NULL, m = 2 and n = 4,return 1->4->3->2->5->NULL.Note:Given m, n sa

2015-07-20 09:43:22 513

原创 [LeetCode][Java] Subsets II

题目:Given a collection of integers that might contain duplicates, nums, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not c

2015-07-19 22:16:30 666

原创 [LeetCode][Java] Gray Code

题目:The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the total number of bits in the code, print the seq

2015-07-19 21:41:43 624

原创 [LeetCode][Java] Merge Sorted Array

题目:Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:You may assume that nums1 has enough space (size that is greater or equal to m + n) to h

2015-07-19 20:55:53 537

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

2015-07-19 20:09:15 647

原创 [LeetCode][Java] Partition List

题目:Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should preserve the original relative order of the nodes i

2015-07-19 12:13:07 829

原创 [LeetCode][Java] 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.题意:给定一个二维的二进制矩阵,矩阵中为0's and 1's,找出最大的全1矩阵的面积。算法分析:这个题真心没有思路,还是看了

2015-07-19 11:55:02 468

空空如也

空空如也

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

TA关注的人

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