博客园 - chkkchuuid:24b78886-0ed1-41c2-8670-e3f31dcf42c4;id=1274212014-10-22T04:12:34Zchkkchhttps://www.cnblogs.com/chkkch/feed.cnblogs.comhttps://www.cnblogs.com/chkkch/p/4042773.htmlFacebook is Hiring! - chkkchI am a software engineer in Facebook. I joined Facebook a year ago and now doing some iOS stuff. If you are interested in Facebook and good at algorit...2014-10-22T04:12:00Z2014-10-22T04:12:00Zchkkchhttps://www.cnblogs.com/chkkch/【摘要】I am a software engineer in Facebook. I joined Facebook a year ago and now doing some iOS stuff. If you are interested in Facebook and good at algorit... <a href="https://www.cnblogs.com/chkkch/p/4042773.html" target="_blank">阅读全文</a>https://www.cnblogs.com/chkkch/p/3401015.html记毕业季的求职经历 - chkkchAccept的公司:Facebook, DeNA, SAP, Intel, ARMFail的公司:阿里巴巴,腾讯,百度,Google,微软,平安科技,豆瓣,雅虎,Amazon,NVIDIA,EMC,VMware,还有各种说不上名字的小公司今年(确切的说是从去年暑假开始)的工作实在不好找。随着国内的经济形势下降,公司的招的人也随之下降得厉害。腾讯,阿里这些往年招生大户今年只招精英,阿里在上海似乎达到了个位数!而我的求职经历应该是从9月开始,而准备则是8月底就开始了。Dream OfferFacebook:说起面FB可能也是当初不经意地投了海外的HR邮箱,然后就安排了skype面试,再之后就是on2013-11-01T01:56:00Z2013-11-01T01:56:00Zchkkchhttps://www.cnblogs.com/chkkch/【摘要】Accept的公司:Facebook, DeNA, SAP, Intel, ARMFail的公司:阿里巴巴,腾讯,百度,Google,微软,平安科技,豆瓣,雅虎,Amazon,NVIDIA,EMC,VMware,还有各种说不上名字的小公司今年(确切的说是从去年暑假开始)的工作实在不好找。随着国内的经济形势下降,公司的招的人也随之下降得厉害。腾讯,阿里这些往年招生大户今年只招精英,阿里在上海似乎达到了个位数!而我的求职经历应该是从9月开始,而准备则是8月底就开始了。Dream OfferFacebook:说起面FB可能也是当初不经意地投了海外的HR邮箱,然后就安排了skype面试,再之后就是on <a href="https://www.cnblogs.com/chkkch/p/3401015.html" target="_blank">阅读全文</a>https://www.cnblogs.com/chkkch/archive/2012/12/02/2798173.html[TopCoder][SRM] SRM 562 DIV 2 - chkkchProblem StatementCucumber Boy likes drawing pictures. Today, he plans to draw a picture using a very simple graphics editor.The editor has the following functions:The canvas is an infinite two-dimensional grid of pixels.There are only two colors: black, and transparent. These are denoted 'B'2012-12-02T06:45:00Z2012-12-02T06:45:00Zchkkchhttps://www.cnblogs.com/chkkch/【摘要】Problem StatementCucumber Boy likes drawing pictures. Today, he plans to draw a picture using a very simple graphics editor.The editor has the following functions:The canvas is an infinite two-dimensional grid of pixels.There are only two colors: black, and transparent. These are denoted 'B' <a href="https://www.cnblogs.com/chkkch/archive/2012/12/02/2798173.html" target="_blank">阅读全文</a>https://www.cnblogs.com/chkkch/archive/2012/12/02/2798140.html[LeetCode] Binary Tree Maximum Path Sum - chkkchGiven 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 3Return6. 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *rig...2012-12-02T06:05:00Z2012-12-02T06:05:00Zchkkchhttps://www.cnblogs.com/chkkch/【摘要】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 3Return6. 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *rig... <a href="https://www.cnblogs.com/chkkch/archive/2012/12/02/2798140.html" target="_blank">阅读全文</a>https://www.cnblogs.com/chkkch/archive/2012/11/29/2795178.html[LeetCode] Best Time to Buy and Sell Stock III - chkkchSay you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete at mosttwotransactions.Note:You may not engage in multiple transactions at the same time (ie, you must sell the stock before you buy again). 1 class So2012-11-29T11:35:00Z2012-11-29T11:35:00Zchkkchhttps://www.cnblogs.com/chkkch/【摘要】Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete at mosttwotransactions.Note:You may not engage in multiple transactions at the same time (ie, you must sell the stock before you buy again). 1 class So <a href="https://www.cnblogs.com/chkkch/archive/2012/11/29/2795178.html" target="_blank">阅读全文</a>https://www.cnblogs.com/chkkch/archive/2012/11/27/2790301.html[LeetCode] Wildcard Matching - chkkchImplement wildcard pattern matching with support for'?'and'*'.'?' Matches any single character.'*' Matches any sequence of characters (including the empty sequence).The matching should cover the entire input string (not partial).The function prototype should be:bool i2012-11-27T02:23:00Z2012-11-27T02:23:00Zchkkchhttps://www.cnblogs.com/chkkch/【摘要】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 the entire input string (not partial).The function prototype should be:bool i <a href="https://www.cnblogs.com/chkkch/archive/2012/11/27/2790301.html" target="_blank">阅读全文</a>https://www.cnblogs.com/chkkch/archive/2012/11/26/2789827.html[LeetCode] Gray Code - chkkchThe gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integernrepresenting the total number of bits in the code, print the sequence of gray code. A gray code sequence must begin with 0.For example, givenn= 2, return[0,1,3,2]. Its gray code s2012-11-26T13:44:00Z2012-11-26T13:44:00Zchkkchhttps://www.cnblogs.com/chkkch/【摘要】The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integernrepresenting the total number of bits in the code, print the sequence of gray code. A gray code sequence must begin with 0.For example, givenn= 2, return[0,1,3,2]. Its gray code s <a href="https://www.cnblogs.com/chkkch/archive/2012/11/26/2789827.html" target="_blank">阅读全文</a>https://www.cnblogs.com/chkkch/archive/2012/11/26/2789822.html[LeetCode] Flatten Binary Tree to Linked List - chkkchGiven 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: 1 \ 2 \ 3 \ 4 \ 5 \ 6Hints:If you notice carefully ...2012-11-26T13:39:00Z2012-11-26T13:39:00Zchkkchhttps://www.cnblogs.com/chkkch/【摘要】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: 1 \ 2 \ 3 \ 4 \ 5 \ 6Hints:If you notice carefully ... <a href="https://www.cnblogs.com/chkkch/archive/2012/11/26/2789822.html" target="_blank">阅读全文</a>https://www.cnblogs.com/chkkch/archive/2012/11/26/2789800.html[LeetCode] Divide Two Integers - chkkchDivide two integers without using multiplication, division and mod operator. 1 class Solution { 2 private: 3 long long f[100]; 4 public: 5 int bsearch(long long a[], int left, int right, long long key) 6 { 7 if (left > right) 8 return -1; 9 10 int ...2012-11-26T13:23:00Z2012-11-26T13:23:00Zchkkchhttps://www.cnblogs.com/chkkch/【摘要】Divide two integers without using multiplication, division and mod operator. 1 class Solution { 2 private: 3 long long f[100]; 4 public: 5 int bsearch(long long a[], int left, int right, long long key) 6 { 7 if (left > right) 8 return -1; 9 10 int ... <a href="https://www.cnblogs.com/chkkch/archive/2012/11/26/2789800.html" target="_blank">阅读全文</a>https://www.cnblogs.com/chkkch/archive/2012/11/26/2789748.html[LeetCode] Implement strStr() - chkkchImplement strStr().Returns a pointer to the first occurrence of needle in haystack, ornullif needle is not part of haystack. 1 class Solution { 2 public: 3 char *strStr(char *haystack, char *needle) { 4 // Start typing your C/C++ solution below 5 // DO NOT write int main() functi...2012-11-26T12:51:00Z2012-11-26T12:51:00Zchkkchhttps://www.cnblogs.com/chkkch/【摘要】Implement strStr().Returns a pointer to the first occurrence of needle in haystack, ornullif needle is not part of haystack. 1 class Solution { 2 public: 3 char *strStr(char *haystack, char *needle) { 4 // Start typing your C/C++ solution below 5 // DO NOT write int main() functi... <a href="https://www.cnblogs.com/chkkch/archive/2012/11/26/2789748.html" target="_blank">阅读全文</a>https://www.cnblogs.com/chkkch/archive/2012/11/26/2788795.html[面试] 二叉树两结点的最低共同父结点 - chkkch题目:二叉树的结点定义如下:structTreeNode{intm_nvalue;TreeNode* m_pLeft;TreeNode* m_pRight;};输入二叉树中的两个结点,输出这两个结点在数中最低的共同父结点。递归版本:空间O(1),时间O(n) 1 struct Node 2 { 3 int val; 4 Node *left; 5 Node *right; 6 Node():left(NULL), right(NULL){} 7 }; 8 9 Node *findFather(Node *root, Node *node1, Node *nod...2012-11-26T04:01:00Z2012-11-26T04:01:00Zchkkchhttps://www.cnblogs.com/chkkch/【摘要】题目:二叉树的结点定义如下:structTreeNode{intm_nvalue;TreeNode* m_pLeft;TreeNode* m_pRight;};输入二叉树中的两个结点,输出这两个结点在数中最低的共同父结点。递归版本:空间O(1),时间O(n) 1 struct Node 2 { 3 int val; 4 Node *left; 5 Node *right; 6 Node():left(NULL), right(NULL){} 7 }; 8 9 Node *findFather(Node *root, Node *node1, Node *nod... <a href="https://www.cnblogs.com/chkkch/archive/2012/11/26/2788795.html" target="_blank">阅读全文</a>https://www.cnblogs.com/chkkch/archive/2012/11/25/2787916.html[LeetCode] Jump Game II - chkkchGiven an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Your goal is to reach the last index in the minimum number of jumps.For example:Given array A =[2,3,1,1,4]The minimum n2012-11-25T12:53:00Z2012-11-25T12:53:00Zchkkchhttps://www.cnblogs.com/chkkch/【摘要】Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Your goal is to reach the last index in the minimum number of jumps.For example:Given array A =[2,3,1,1,4]The minimum n <a href="https://www.cnblogs.com/chkkch/archive/2012/11/25/2787916.html" target="_blank">阅读全文</a>https://www.cnblogs.com/chkkch/archive/2012/11/25/2787878.html[LeetCode] Longest Valid Parentheses - chkkchGiven 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"()", which has length = 2.Another example is")()())", where the longest 2012-11-25T12:26:00Z2012-11-25T12:26:00Zchkkchhttps://www.cnblogs.com/chkkch/【摘要】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"()", which has length = 2.Another example is")()())", where the longest <a href="https://www.cnblogs.com/chkkch/archive/2012/11/25/2787878.html" target="_blank">阅读全文</a>https://www.cnblogs.com/chkkch/archive/2012/11/25/2787857.html[LeetCode] Populating Next Right Pointers in Each Node II - chkkchFollow 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 extra space.For example,Given the following binary tree, 1 / \ 2 3 / \ \ 4 5 ...2012-11-25T12:08:00Z2012-11-25T12:08:00Zchkkchhttps://www.cnblogs.com/chkkch/【摘要】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 extra space.For example,Given the following binary tree, 1 / \ 2 3 / \ \ 4 5 ... <a href="https://www.cnblogs.com/chkkch/archive/2012/11/25/2787857.html" target="_blank">阅读全文</a>https://www.cnblogs.com/chkkch/archive/2012/11/25/2787822.html[LeetCode] Trapping Rain Water - chkkchGivennnon-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.For example,Given[0,1,0,2,1,0,1,3,2,1,2,1], return6.The above elevation map is represented by array [0,1,0,2,1,0,1,3,2,1,2,1]. In this case, 6 units of 2012-11-25T11:26:00Z2012-11-25T11:26:00Zchkkchhttps://www.cnblogs.com/chkkch/【摘要】Givennnon-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.For example,Given[0,1,0,2,1,0,1,3,2,1,2,1], return6.The above elevation map is represented by array [0,1,0,2,1,0,1,3,2,1,2,1]. In this case, 6 units of <a href="https://www.cnblogs.com/chkkch/archive/2012/11/25/2787822.html" target="_blank">阅读全文</a>https://www.cnblogs.com/chkkch/archive/2012/11/25/2787739.html[LeetCode] Sort Colors - chkkchGiven an array withnobjects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will use the integers 0, 1, and 2 to represent the color red, white, and blue respectively.Note:You are not suppose to use the l2012-11-25T09:45:00Z2012-11-25T09:45:00Zchkkchhttps://www.cnblogs.com/chkkch/【摘要】Given an array withnobjects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will use the integers 0, 1, and 2 to represent the color red, white, and blue respectively.Note:You are not suppose to use the l <a href="https://www.cnblogs.com/chkkch/archive/2012/11/25/2787739.html" target="_blank">阅读全文</a>https://www.cnblogs.com/chkkch/archive/2012/11/25/2787564.html[LeetCode] Search in Rotated Sorted Array II - chkkchFollow up for "Search in Rotated Sorted Array":What ifduplicatesare allowed?Would this affect the run-time complexity? How and why?Write a function to determine if a given target is in the array. 1 class Solution { 2 public: 3 int findPos(int a[], int left, int right) 4 { 5 if (left ...2012-11-25T06:40:00Z2012-11-25T06:40:00Zchkkchhttps://www.cnblogs.com/chkkch/【摘要】Follow up for "Search in Rotated Sorted Array":What ifduplicatesare allowed?Would this affect the run-time complexity? How and why?Write a function to determine if a given target is in the array. 1 class Solution { 2 public: 3 int findPos(int a[], int left, int right) 4 { 5 if (left ... <a href="https://www.cnblogs.com/chkkch/archive/2012/11/25/2787564.html" target="_blank">阅读全文</a>https://www.cnblogs.com/chkkch/archive/2012/11/25/2787533.html[LeetCode] Populating Next Right Pointers in Each Node - chkkchGiven a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set toNULL.Initially, all next pointers are set toNULL.N...2012-11-25T06:13:00Z2012-11-25T06:13:00Zchkkchhttps://www.cnblogs.com/chkkch/【摘要】Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set toNULL.Initially, all next pointers are set toNULL.N... <a href="https://www.cnblogs.com/chkkch/archive/2012/11/25/2787533.html" target="_blank">阅读全文</a>https://www.cnblogs.com/chkkch/archive/2012/11/25/2787483.html[LeetCode] Next Permutation - chkkchImplement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest possible order (ie, sorted in ascending order).The replacement must be in-place, do not allocate extra memory.He2012-11-25T05:25:00Z2012-11-25T05:25:00Zchkkchhttps://www.cnblogs.com/chkkch/【摘要】Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest possible order (ie, sorted in ascending order).The replacement must be in-place, do not allocate extra memory.He <a href="https://www.cnblogs.com/chkkch/archive/2012/11/25/2787483.html" target="_blank">阅读全文</a>https://www.cnblogs.com/chkkch/archive/2012/11/25/2787407.html[LeetCode] Insert Interval - chkkchGiven a set ofnon-overlappingintervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initially sorted according to their start times.Example 1:Given intervals[1,3],[6,9], insert and merge[2,5]in as[1,5],[6,9].Example 2:Given[1,2],[3,5],[6,7],[82012-11-25T04:10:00Z2012-11-25T04:10:00Zchkkchhttps://www.cnblogs.com/chkkch/【摘要】Given a set ofnon-overlappingintervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initially sorted according to their start times.Example 1:Given intervals[1,3],[6,9], insert and merge[2,5]in as[1,5],[6,9].Example 2:Given[1,2],[3,5],[6,7],[8 <a href="https://www.cnblogs.com/chkkch/archive/2012/11/25/2787407.html" target="_blank">阅读全文</a>