<?xml version="1.0" encoding="utf-8" ?><rss version="2.0"><channel><title><![CDATA[likecool21的专栏]]></title><description><![CDATA[]]></description><link>https://blog.youkuaiyun.com/likecool21</link><language>zh-cn</language><generator>https://blog.youkuaiyun.com/</generator><copyright><![CDATA[Copyright &copy; likecool21]]></copyright><item><title><![CDATA[Largest BST in a Binary Tree]]></title><link>https://blog.youkuaiyun.com/likecool21/article/details/44080779</link><guid>https://blog.youkuaiyun.com/likecool21/article/details/44080779</guid><author>likecool21</author><pubDate>Thu, 05 Mar 2015 12:11:59 +0800</pubDate><description><![CDATA[一到面试题，挺有意思的。
简单做法是对于每个node都进行一遍isBST的测试，找出最大的那个。
public static int largestBSTNaive(TreeNode root){
		if(isBST(root)){
			return size(root);
		}
		return Math.max(largestBSTNaive(root.left), largestB]]></description><category></category></item><item><title><![CDATA[LeetCode刷题笔录dungeon game]]></title><link>https://blog.youkuaiyun.com/likecool21/article/details/42516979</link><guid>https://blog.youkuaiyun.com/likecool21/article/details/42516979</guid><author>likecool21</author><pubDate>Thu, 08 Jan 2015 04:27:02 +0800</pubDate><description><![CDATA[The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out in a 2D grid. Our valiant knight (K)
 was initially p]]></description><category></category></item><item><title><![CDATA[LeetCode刷提笔录Scramble String]]></title><link>https://blog.youkuaiyun.com/likecool21/article/details/42000727</link><guid>https://blog.youkuaiyun.com/likecool21/article/details/42000727</guid><author>likecool21</author><pubDate>Thu, 18 Dec 2014 07:05:53 +0800</pubDate><description><![CDATA[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  ]]></description><category></category></item><item><title><![CDATA[LeetCode刷题笔录Interleaving String]]></title><link>https://blog.youkuaiyun.com/likecool21/article/details/41955701</link><guid>https://blog.youkuaiyun.com/likecool21/article/details/41955701</guid><author>likecool21</author><pubDate>Tue, 16 Dec 2014 06:46:06 +0800</pubDate><description><![CDATA[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", return]]></description><category></category></item><item><title><![CDATA[LeetCode刷题笔录Sort List]]></title><link>https://blog.youkuaiyun.com/likecool21/article/details/41594989</link><guid>https://blog.youkuaiyun.com/likecool21/article/details/41594989</guid><author>likecool21</author><pubDate>Sat, 29 Nov 2014 13:18:48 +0800</pubDate><description><![CDATA[Sort a linked list in O(n log n)
 time using constant space complexity.

挺有意思的题，这里用了merge sort，可以利用到merge sorted list 那题的代码




/**
 * Definition for singly-linked list.
 * class ListNode {
 *]]></description><category></category></item><item><title><![CDATA[LeetCode刷题笔录Maximal Rectangle]]></title><link>https://blog.youkuaiyun.com/likecool21/article/details/41117349</link><guid>https://blog.youkuaiyun.com/likecool21/article/details/41117349</guid><author>likecool21</author><pubDate>Fri, 14 Nov 2014 13:29:45 +0800</pubDate><description><![CDATA[Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.


这题要用到]]></description><category></category></item><item><title><![CDATA[LeetCode刷题笔录Word Break II]]></title><link>https://blog.youkuaiyun.com/likecool21/article/details/40894601</link><guid>https://blog.youkuaiyun.com/likecool21/article/details/40894601</guid><author>likecool21</author><pubDate>Fri, 07 Nov 2014 16:18:23 +0800</pubDate><description><![CDATA[Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word.

Return all such possible sentences.

For example, given
s = "]]></description><category></category></item><item><title><![CDATA[LeetCode刷题笔录Longest Valid Parentheses]]></title><link>https://blog.youkuaiyun.com/likecool21/article/details/40893249</link><guid>https://blog.youkuaiyun.com/likecool21/article/details/40893249</guid><author>likecool21</author><pubDate>Fri, 07 Nov 2014 15:15:14 +0800</pubDate><description><![CDATA[Given a string containing just the characters '(' and ')',
 find the length of the longest valid (well-formed) parentheses substring.

For "(()", the longest valid parentheses substring is "()",
 ]]></description><category></category></item><item><title><![CDATA[LeetCode刷题笔录Wildcard Matching]]></title><link>https://blog.youkuaiyun.com/likecool21/article/details/40887307</link><guid>https://blog.youkuaiyun.com/likecool21/article/details/40887307</guid><author>likecool21</author><pubDate>Fri, 07 Nov 2014 08:01:15 +0800</pubDate><description><![CDATA[Implement wildcard pattern matching with support for '?' and '*'.
'?' Matches any single character.
'*' Matches any sequence of characters (including the empty sequence).

The matching should cover t]]></description><category></category></item><item><title><![CDATA[LeetCode刷题笔录Max Points on a Line]]></title><link>https://blog.youkuaiyun.com/likecool21/article/details/40884957</link><guid>https://blog.youkuaiyun.com/likecool21/article/details/40884957</guid><author>likecool21</author><pubDate>Fri, 07 Nov 2014 04:45:29 +0800</pubDate><description><![CDATA[Given n points
 on a 2D plane, find the maximum number of points that lie on the same straight line.


两个点是必然gong'xian]]></description><category></category></item><item><title><![CDATA[LeetCode刷题笔录Largest Rectangle in Histogram]]></title><link>https://blog.youkuaiyun.com/likecool21/article/details/40860561</link><guid>https://blog.youkuaiyun.com/likecool21/article/details/40860561</guid><author>likecool21</author><pubDate>Thu, 06 Nov 2014 14:44:49 +0800</pubDate><description><![CDATA[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]]></description><category></category></item><item><title><![CDATA[LeetCode刷题笔录Binary Tree Maximum Path Sum]]></title><link>https://blog.youkuaiyun.com/likecool21/article/details/40821443</link><guid>https://blog.youkuaiyun.com/likecool21/article/details/40821443</guid><author>likecool21</author><pubDate>Wed, 05 Nov 2014 12:47:41 +0800</pubDate><description><![CDATA[这题试了很多次也没成功，从网上找了段d]]></description><category></category></item><item><title><![CDATA[LeetCode刷题笔录Simplify Path]]></title><link>https://blog.youkuaiyun.com/likecool21/article/details/40613853</link><guid>https://blog.youkuaiyun.com/likecool21/article/details/40613853</guid><author>likecool21</author><pubDate>Thu, 30 Oct 2014 08:19:00 +0800</pubDate><description><![CDATA[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 ]]></description><category></category></item><item><title><![CDATA[LeetCode刷题笔录Permutation Sequence]]></title><link>https://blog.youkuaiyun.com/likecool21/article/details/40572339</link><guid>https://blog.youkuaiyun.com/likecool21/article/details/40572339</guid><author>likecool21</author><pubDate>Wed, 29 Oct 2014 08:37:23 +0800</pubDate><description><![CDATA[The set [1,2,3,…,n] contains a total of n! unique
 permutations.

By listing and labeling all of the permutations in order,
We get the following sequence (ie, for n = 3):

"123""132""213""231""3]]></description><category></category></item><item><title><![CDATA[LeetCode刷题笔录Evaluate Reverse Polish Notation]]></title><link>https://blog.youkuaiyun.com/likecool21/article/details/40535543</link><guid>https://blog.youkuaiyun.com/likecool21/article/details/40535543</guid><author>likecool21</author><pubDate>Tue, 28 Oct 2014 09:30:25 +0800</pubDate><description><![CDATA[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", ]]></description><category></category></item><item><title><![CDATA[LeetCode刷题笔录LRUCache]]></title><link>https://blog.youkuaiyun.com/likecool21/article/details/40464687</link><guid>https://blog.youkuaiyun.com/likecool21/article/details/40464687</guid><author>likecool21</author><pubDate>Sun, 26 Oct 2014 01:30:49 +0800</pubDate><description><![CDATA[Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set.
get(key) -
 Get the value (will always be positive) of the key if ]]></description><category></category></item><item><title><![CDATA[LeetCode刷题笔录Reverse Words in a String]]></title><link>https://blog.youkuaiyun.com/likecool21/article/details/40146253</link><guid>https://blog.youkuaiyun.com/likecool21/article/details/40146253</guid><author>likecool21</author><pubDate>Thu, 16 Oct 2014 12:34:14 +0800</pubDate><description><![CDATA[https://oj.leetcode.com/problems/reverse-words-in-a-string/


我的做法是从后往前扫描，遇到空格就]]></description><category></category></item><item><title><![CDATA[LeetCode刷题笔录Permutations II]]></title><link>https://blog.youkuaiyun.com/likecool21/article/details/40104981</link><guid>https://blog.youkuaiyun.com/likecool21/article/details/40104981</guid><author>likecool21</author><pubDate>Wed, 15 Oct 2014 06:02:49 +0800</pubDate><description><![CDATA[Given a collection of numbers that might contain duplicates, return all possible unique permutations.
For example,
[1,1,2] have
 the following unique permutations:


[1,1,2], [1,2,1],
 and [2,1]]></description><category></category></item><item><title><![CDATA[LeetCode刷题笔录Remove Duplicates from Sorted List II]]></title><link>https://blog.youkuaiyun.com/likecool21/article/details/39887877</link><guid>https://blog.youkuaiyun.com/likecool21/article/details/39887877</guid><author>likecool21</author><pubDate>Wed, 08 Oct 2014 05:38:14 +0800</pubDate><description><![CDATA[Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.

For example,
Given 1->2->3->3->4->4->5, return 1->2->5.

Given 1->]]></description><category></category></item><item><title><![CDATA[LeetCode刷题笔录Reverse Linked List II]]></title><link>https://blog.youkuaiyun.com/likecool21/article/details/39824951</link><guid>https://blog.youkuaiyun.com/likecool21/article/details/39824951</guid><author>likecool21</author><pubDate>Mon, 06 Oct 2014 07:02:39 +0800</pubDate><description><![CDATA[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 satisfy t]]></description><category></category></item></channel></rss>