<?xml version="1.0" encoding="utf-8" ?><rss version="2.0"><channel><title><![CDATA[benbenab的专栏]]></title><description><![CDATA[]]></description><link>https://blog.youkuaiyun.com/benbenab</link><language>zh-cn</language><generator>https://blog.youkuaiyun.com/</generator><copyright><![CDATA[Copyright &copy; benbenab]]></copyright><item><title><![CDATA[LeetCode Single Number I & II 都符合两个问题额外要求的 通用解法 与 思考过程]]></title><link>https://blog.youkuaiyun.com/benbenab/article/details/39825873</link><guid>https://blog.youkuaiyun.com/benbenab/article/details/39825873</guid><author>benbenab</author><pubDate>Mon, 06 Oct 2014 12:34:50 +0800</pubDate><description><![CDATA[Single Number

Given an array of integers, every element appears twice except for one. Find that single one.

Note:
Your algorithm should have a linear runtime complexity. Could you implement it ]]></description><category></category></item><item><title><![CDATA[Linked List Cycle]]></title><link>https://blog.youkuaiyun.com/benbenab/article/details/39669567</link><guid>https://blog.youkuaiyun.com/benbenab/article/details/39669567</guid><author>benbenab</author><pubDate>Mon, 29 Sep 2014 14:49:40 +0800</pubDate><description><![CDATA[Given a linked list, determine if it has a cycle in it.

Follow up:

Can you solve it without using extra space?]]></description><category></category></item><item><title><![CDATA[[leetcode ] gray code]]></title><link>https://blog.youkuaiyun.com/benbenab/article/details/17530397</link><guid>https://blog.youkuaiyun.com/benbenab/article/details/17530397</guid><author>benbenab</author><pubDate>Tue, 24 Dec 2013 15:31:00 +0800</pubDate><description><![CDATA[class Solution {
public:
    vector grayCode(int n) {
        vector results;
        do{
            if (n < 0)
                break;
            else if (n == 0)
            {
                resul]]></description><category></category></item><item><title><![CDATA[Maximum Subarrary]]></title><link>https://blog.youkuaiyun.com/benbenab/article/details/12778393</link><guid>https://blog.youkuaiyun.com/benbenab/article/details/12778393</guid><author>benbenab</author><pubDate>Wed, 16 Oct 2013 13:18:45 +0800</pubDate><description><![CDATA[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,−5,4],
the contiguous subarray [4,−1,2,1] ha]]></description><category></category></item><item><title><![CDATA[[leetcode]]]></title><link>https://blog.youkuaiyun.com/benbenab/article/details/12428049</link><guid>https://blog.youkuaiyun.com/benbenab/article/details/12428049</guid><author>benbenab</author><pubDate>Tue, 08 Oct 2013 13:01:56 +0800</pubDate><description><![CDATA[Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.

You may assume no duplicates in the array.]]></description><category></category></item><item><title><![CDATA[reverse interger]]></title><link>https://blog.youkuaiyun.com/benbenab/article/details/11845849</link><guid>https://blog.youkuaiyun.com/benbenab/article/details/11845849</guid><author>benbenab</author><pubDate>Fri, 20 Sep 2013 13:40:27 +0800</pubDate><description><![CDATA[Reverse digits of an integer.


Example1: x = 123, return 321
Example2: x = -123, return -321

Have you thought about this?

Here are some good questions to ask before coding. Bonus points for]]></description><category></category></item><item><title><![CDATA[[leetcode ]  word search]]></title><link>https://blog.youkuaiyun.com/benbenab/article/details/8624480</link><guid>https://blog.youkuaiyun.com/benbenab/article/details/8624480</guid><author>benbenab</author><pubDate>Fri, 01 Mar 2013 03:20:16 +0800</pubDate><description><![CDATA[Given a 2D board and a word, find if the word exists in the grid.

The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically]]></description><category></category></item><item><title><![CDATA[Divide Two Integers]]></title><link>https://blog.youkuaiyun.com/benbenab/article/details/8564994</link><guid>https://blog.youkuaiyun.com/benbenab/article/details/8564994</guid><author>benbenab</author><pubDate>Sat, 02 Feb 2013 13:07:45 +0800</pubDate><description><![CDATA[class Solution {
public:
    int divide(int dividend, int divisor) {
        // Start typing your C/C++ solution below
        // DO NOT write int main() function
        if (divisor == 0)]]></description><category></category></item><item><title><![CDATA[Search for a Range !!!]]></title><link>https://blog.youkuaiyun.com/benbenab/article/details/8564597</link><guid>https://blog.youkuaiyun.com/benbenab/article/details/8564597</guid><author>benbenab</author><pubDate>Sat, 02 Feb 2013 08:44:24 +0800</pubDate><description><![CDATA[Given a sorted array of integers, find the starting and ending position of a given target value.
Your algorithm's runtime complexity must be in the order of O(log n).
If the target is not found in t]]></description><category></category></item><item><title><![CDATA[【leetcode】 Populating Next Right Pointers in Each Node]]></title><link>https://blog.youkuaiyun.com/benbenab/article/details/8558958</link><guid>https://blog.youkuaiyun.com/benbenab/article/details/8558958</guid><author>benbenab</author><pubDate>Thu, 31 Jan 2013 11:35:03 +0800</pubDate><description><![CDATA[Given a binary tree    struct TreeLinkNode {
      TreeLinkNode *left;
      TreeLinkNode *right;
      TreeLinkNode *next;
    }




Populate each next pointer to point to its next right node. If]]></description><category></category></item><item><title><![CDATA[[leetcode]  Rotate List]]></title><link>https://blog.youkuaiyun.com/benbenab/article/details/8547530</link><guid>https://blog.youkuaiyun.com/benbenab/article/details/8547530</guid><author>benbenab</author><pubDate>Mon, 28 Jan 2013 03:26:48 +0800</pubDate><description><![CDATA[Given a list, rotate the list to the right by k places, where k is
 non-negative.

For example:
Given 1->2->3->4->5->NULL and k = 2,
return 4->5->1->2->3->NULL.

/**
 * Definition for singly-li]]></description><category></category></item><item><title><![CDATA[求最大prime]]></title><link>https://blog.youkuaiyun.com/benbenab/article/details/8547480</link><guid>https://blog.youkuaiyun.com/benbenab/article/details/8547480</guid><author>benbenab</author><pubDate>Mon, 28 Jan 2013 00:50:23 +0800</pubDate><description><![CDATA[不知道这个的复杂度怎么分析。 不过worst case 应该是O（n），average 可能是O(sqrt(n))
int maxPrime(int n)
{
    assert(n>=0);
    if(n <= 3) return n;
    int k = 1;
    while(n > 1)
    {
        ++k;
        if(k > n / k) ret]]></description><category></category></item><item><title><![CDATA[【leetcode】 generate parenthesis ！！]]></title><link>https://blog.youkuaiyun.com/benbenab/article/details/8537914</link><guid>https://blog.youkuaiyun.com/benbenab/article/details/8537914</guid><author>benbenab</author><pubDate>Thu, 24 Jan 2013 14:12:57 +0800</pubDate><description><![CDATA[class Solution {
 private:
     vector ret;
 public:
     void solve(int dep, int maxDep, int leftNum, int leftNumTotal, string s)
     {
         if (leftNumTotal * 2 > maxDep)
             return;]]></description><category></category></item><item><title><![CDATA[[leetcode] simplify path]]></title><link>https://blog.youkuaiyun.com/benbenab/article/details/8533067</link><guid>https://blog.youkuaiyun.com/benbenab/article/details/8533067</guid><author>benbenab</author><pubDate>Wed, 23 Jan 2013 10:54:05 +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"


Corner Cases:




Did you consider the case w]]></description><category></category></item><item><title><![CDATA[leetcode power (x,n)]]></title><link>https://blog.youkuaiyun.com/benbenab/article/details/8532200</link><guid>https://blog.youkuaiyun.com/benbenab/article/details/8532200</guid><author>benbenab</author><pubDate>Wed, 23 Jan 2013 08:08:07 +0800</pubDate><description><![CDATA[1. 考虑double float 的相等，不能仅仅用==表示，是有精度限制的。
2.  n 大于0，小于0的情况
3. if (temp_diveded & 1)
                result *= base;
            base *= base;
            temp_diveded >>= 1;
想法很赞！！！！


#define AC]]></description><category></category></item><item><title><![CDATA[[leetcode] Remove Duplicates from Sorted List II]]></title><link>https://blog.youkuaiyun.com/benbenab/article/details/8532179</link><guid>https://blog.youkuaiyun.com/benbenab/article/details/8532179</guid><author>benbenab</author><pubDate>Wed, 23 Jan 2013 06:49:34 +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[Segment a long string into a set of valid words using a dictionary]]></title><link>https://blog.youkuaiyun.com/benbenab/article/details/8505300</link><guid>https://blog.youkuaiyun.com/benbenab/article/details/8505300</guid><author>benbenab</author><pubDate>Tue, 15 Jan 2013 13:24:06 +0800</pubDate><description><![CDATA[http://thenoisychannel.com/2011/08/08/retiring-a-great-interview-problem/


有牛人能给解释一下为什么是O(2^n) 和 O(n^2)?]]></description><category></category></item><item><title><![CDATA[given stream of integers, find first 100 large numbers (!!!)]]></title><link>https://blog.youkuaiyun.com/benbenab/article/details/8495447</link><guid>https://blog.youkuaiyun.com/benbenab/article/details/8495447</guid><author>benbenab</author><pubDate>Sat, 12 Jan 2013 07:19:45 +0800</pubDate><description><![CDATA[最开始的idea很自然想到用heap，size为100的heap, 计算复杂度为O(nlog100).
不如用bubble sort，bubble100次，因为不需要让这100个数sorted，O(100n) = O(n)]]></description><category></category></item><item><title><![CDATA[【FB】]]></title><link>https://blog.youkuaiyun.com/benbenab/article/details/8487988</link><guid>https://blog.youkuaiyun.com/benbenab/article/details/8487988</guid><author>benbenab</author><pubDate>Thu, 10 Jan 2013 00:59:54 +0800</pubDate><description><![CDATA[小肥的面经，小肥的代码：http://collabedit.com/gmysb






1. 开会的题目，问给一堆会议，每个会议一个开始时间，结束时间，问有没有 overlap







2. 如果这些会议有overlap 求最小需要多少房间






第二个解法简直是精典！
struct Meeting{
    double start;]]></description><category></category></item><item><title><![CDATA[[leetcode]longest Valid Parentheses(!!)]]></title><link>https://blog.youkuaiyun.com/benbenab/article/details/8479274</link><guid>https://blog.youkuaiyun.com/benbenab/article/details/8479274</guid><author>benbenab</author><pubDate>Tue, 08 Jan 2013 06:00:56 +0800</pubDate><description><![CDATA[class Solution {
public:
    int longestValidParentheses(string s) {
        // Start typing your C/C++ solution below
        // DO NOT write int main() function
        int nSize = s.size();]]></description><category></category></item></channel></rss>