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...
摘要:
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' 阅读全文
摘要:
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... 阅读全文
摘要:
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 阅读全文
摘要:
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 阅读全文
摘要:
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 阅读全文
摘要:
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 ... 阅读全文
摘要:
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 ... 阅读全文
摘要:
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... 阅读全文