<?xml version="1.0" encoding="utf-8" ?><rss version="2.0"><channel><title><![CDATA[CiaoLiang的专栏]]></title><description><![CDATA[]]></description><link>https://blog.youkuaiyun.com/CiaoLiang</link><language>zh-cn</language><generator>https://blog.youkuaiyun.com/</generator><copyright><![CDATA[Copyright &copy; CiaoLiang]]></copyright><item><title><![CDATA[Top K Frequent Elements]]></title><link>https://blog.youkuaiyun.com/CiaoLiang/article/details/51372135</link><guid>https://blog.youkuaiyun.com/CiaoLiang/article/details/51372135</guid><author>CiaoLiang</author><pubDate>Wed, 11 May 2016 10:18:01 +0800</pubDate><description><![CDATA[Given a non-empty array of integers, return the k most frequent elements.

For example,
Given [1,1,1,2,2,3] and k = 2, return [1,2].

Note: 


You may assume k is always valid, 1 ≤ k ≤ number ]]></description><category></category></item><item><title><![CDATA[[LeetCode]Integer Break]]></title><link>https://blog.youkuaiyun.com/CiaoLiang/article/details/51190503</link><guid>https://blog.youkuaiyun.com/CiaoLiang/article/details/51190503</guid><author>CiaoLiang</author><pubDate>Tue, 19 Apr 2016 14:54:46 +0800</pubDate><description><![CDATA[Integer Break


Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get.

For exampl]]></description><category></category></item><item><title><![CDATA[[LeetCode]LRU Cache]]></title><link>https://blog.youkuaiyun.com/CiaoLiang/article/details/51182439</link><guid>https://blog.youkuaiyun.com/CiaoLiang/article/details/51182439</guid><author>CiaoLiang</author><pubDate>Mon, 18 Apr 2016 20:20:51 +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]Power of Four]]></title><link>https://blog.youkuaiyun.com/CiaoLiang/article/details/51180328</link><guid>https://blog.youkuaiyun.com/CiaoLiang/article/details/51180328</guid><author>CiaoLiang</author><pubDate>Mon, 18 Apr 2016 16:08:38 +0800</pubDate><description><![CDATA[Given an integer (signed 32 bits), write a function to check whether it is a power of 4.

Example:
Given num = 16, return true. Given num = 5, return false.

Follow up: Could you solve it without]]></description><category></category></item><item><title><![CDATA[[LeetCode]Repeated DNA Sequences]]></title><link>https://blog.youkuaiyun.com/CiaoLiang/article/details/51180302</link><guid>https://blog.youkuaiyun.com/CiaoLiang/article/details/51180302</guid><author>CiaoLiang</author><pubDate>Mon, 18 Apr 2016 16:03:02 +0800</pubDate><description><![CDATA[All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG". When studying DNA, it is sometimes useful to identify repeated sequences within the DNA.

Wri]]></description><category></category></item><item><title><![CDATA[[LeetCode]Clone Graph]]></title><link>https://blog.youkuaiyun.com/CiaoLiang/article/details/51175606</link><guid>https://blog.youkuaiyun.com/CiaoLiang/article/details/51175606</guid><author>CiaoLiang</author><pubDate>Sun, 17 Apr 2016 21:32:15 +0800</pubDate><description><![CDATA[Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.


OJ's undirected graph serialization:
Nodes are labeled uniquely.
We use # as a separator for each]]></description><category></category></item><item><title><![CDATA[[LeetCode]Word Ladder II]]></title><link>https://blog.youkuaiyun.com/CiaoLiang/article/details/51174624</link><guid>https://blog.youkuaiyun.com/CiaoLiang/article/details/51174624</guid><author>CiaoLiang</author><pubDate>Sun, 17 Apr 2016 19:06:25 +0800</pubDate><description><![CDATA[Word Ladder II
   



Given two words (beginWord and endWord), and a dictionary's word list, find all shortest transformation sequence(s) from beginWord to endWord,
 such that:

Only one lette]]></description><category></category></item><item><title><![CDATA[[LeetCode]Basic Calculator]]></title><link>https://blog.youkuaiyun.com/CiaoLiang/article/details/51013809</link><guid>https://blog.youkuaiyun.com/CiaoLiang/article/details/51013809</guid><author>CiaoLiang</author><pubDate>Wed, 30 Mar 2016 13:52:57 +0800</pubDate><description><![CDATA[Implement a basic calculator to evaluate a simple expression string.

The expression string may contain open ( and closing parentheses ),
 the plus + or minus sign -, non-negative integers
 and em]]></description><category></category></item><item><title><![CDATA[[LeetCode]Insertion Sort List]]></title><link>https://blog.youkuaiyun.com/CiaoLiang/article/details/51007468</link><guid>https://blog.youkuaiyun.com/CiaoLiang/article/details/51007468</guid><author>CiaoLiang</author><pubDate>Tue, 29 Mar 2016 17:07:09 +0800</pubDate><description><![CDATA[Sort a linked list using insertion sort.

写个子函数把最后一个节点插入到合适的位置。

注意每次插入后链表值改变了。

class Solution {
public:
    ListNode* insertionSortList(ListNode* head) {
        if(head == nullptr) return nul]]></description><category></category></item><item><title><![CDATA[[LeetCode]H-Index II]]></title><link>https://blog.youkuaiyun.com/CiaoLiang/article/details/51005491</link><guid>https://blog.youkuaiyun.com/CiaoLiang/article/details/51005491</guid><author>CiaoLiang</author><pubDate>Tue, 29 Mar 2016 14:33:42 +0800</pubDate><description><![CDATA[Follow up for H-Index:
 What if the citations array
 is sorted in ascending order? Could you optimize your algorithm?
对排好序的求H index，可以想到采用Binary Search。把搜寻规则稍微改一下。
class Solution {
public:
    int]]></description><category></category></item><item><title><![CDATA[[LeetCode]H-Index]]></title><link>https://blog.youkuaiyun.com/CiaoLiang/article/details/51005085</link><guid>https://blog.youkuaiyun.com/CiaoLiang/article/details/51005085</guid><author>CiaoLiang</author><pubDate>Tue, 29 Mar 2016 13:21:02 +0800</pubDate><description><![CDATA[Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-index.

According to the definition of h-index on Wikipedia: "A]]></description><category></category></item><item><title><![CDATA[[LeetCode]Different Ways to Add Parentheses]]></title><link>https://blog.youkuaiyun.com/CiaoLiang/article/details/50997596</link><guid>https://blog.youkuaiyun.com/CiaoLiang/article/details/50997596</guid><author>CiaoLiang</author><pubDate>Mon, 28 Mar 2016 14:23:13 +0800</pubDate><description><![CDATA[Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. The valid operators are +,- and *.

Example 1

I]]></description><category></category></item><item><title><![CDATA[[LeetCode]Combination Sum III]]></title><link>https://blog.youkuaiyun.com/CiaoLiang/article/details/50991180</link><guid>https://blog.youkuaiyun.com/CiaoLiang/article/details/50991180</guid><author>CiaoLiang</author><pubDate>Sun, 27 Mar 2016 12:58:44 +0800</pubDate><description><![CDATA[Find all possible combinations of k numbers that add up to a number n, given that only numbers
 from 1 to 9 can be used and each combination should be a unique set of numbers.
Ensure that numbers wi]]></description><category></category></item><item><title><![CDATA[[LeetCode] House Robber III]]></title><link>https://blog.youkuaiyun.com/CiaoLiang/article/details/50987744</link><guid>https://blog.youkuaiyun.com/CiaoLiang/article/details/50987744</guid><author>CiaoLiang</author><pubDate>Sat, 26 Mar 2016 17:08:59 +0800</pubDate><description><![CDATA[The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the "root." Besides the root, each house has one and only one parent house. After a tour]]></description><category></category></item><item><title><![CDATA[[LeetCode]Maximum Product of Word Lengths]]></title><link>https://blog.youkuaiyun.com/CiaoLiang/article/details/50987382</link><guid>https://blog.youkuaiyun.com/CiaoLiang/article/details/50987382</guid><author>CiaoLiang</author><pubDate>Sat, 26 Mar 2016 16:19:06 +0800</pubDate><description><![CDATA[Given a string array words, find the maximum value of length(word[i])
 * length(word[j]) where the two words do not share common letters. You may assume that each word will contain only lower case le]]></description><category></category></item><item><title><![CDATA[[LeetCode]Missing Number]]></title><link>https://blog.youkuaiyun.com/CiaoLiang/article/details/50986611</link><guid>https://blog.youkuaiyun.com/CiaoLiang/article/details/50986611</guid><author>CiaoLiang</author><pubDate>Sat, 26 Mar 2016 14:08:57 +0800</pubDate><description><![CDATA[Given an array containing n distinct numbers taken from 0, 1, 2, ..., n,
 find the one that is missing from the array.

For example,
Given nums = [0, 1, 3] return 2.

Note:

Your algorithm sho]]></description><category></category></item><item><title><![CDATA[[LeetCode]Single Number III]]></title><link>https://blog.youkuaiyun.com/CiaoLiang/article/details/50986553</link><guid>https://blog.youkuaiyun.com/CiaoLiang/article/details/50986553</guid><author>CiaoLiang</author><pubDate>Sat, 26 Mar 2016 14:00:04 +0800</pubDate><description><![CDATA[Given an array of numbers nums, in which exactly two elements appear only once and all
 the other elements appear exactly twice. Find the two elements that appear only once.

For example:

Given ]]></description><category></category></item><item><title><![CDATA[[LeetCode]Count Primes]]></title><link>https://blog.youkuaiyun.com/CiaoLiang/article/details/50985761</link><guid>https://blog.youkuaiyun.com/CiaoLiang/article/details/50985761</guid><author>CiaoLiang</author><pubDate>Sat, 26 Mar 2016 10:51:08 +0800</pubDate><description><![CDATA[Description:

Count the number of prime numbers less than a non-negative number, n.



参考https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes

class Solution {
public:
    int countPrimes(int n]]></description><category></category></item><item><title><![CDATA[[LeetCode]Palindrome Linked List]]></title><link>https://blog.youkuaiyun.com/CiaoLiang/article/details/50985605</link><guid>https://blog.youkuaiyun.com/CiaoLiang/article/details/50985605</guid><author>CiaoLiang</author><pubDate>Sat, 26 Mar 2016 10:25:33 +0800</pubDate><description><![CDATA[Given a singly linked list, determine if it is a palindrome.
利用之前完成的link 翻转。首先找到中间节点，然后对后半link翻转和前半段对比。如果一样说明link是回文。
/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 ]]></description><category></category></item><item><title><![CDATA[[LeetCode]Binary Tree Paths]]></title><link>https://blog.youkuaiyun.com/CiaoLiang/article/details/50983829</link><guid>https://blog.youkuaiyun.com/CiaoLiang/article/details/50983829</guid><author>CiaoLiang</author><pubDate>Fri, 25 Mar 2016 20:41:46 +0800</pubDate><description><![CDATA[Given a binary tree, return all root-to-leaf paths.

For example, given the following binary tree:


   1
 /   \
2     3
 \
  5




All root-to-leaf paths are:
["1->2->5", "1->3"]



中序遍]]></description><category></category></item></channel></rss>