09 2017 档案
摘要:Given a string that contains only digits 0-9 and a target value, return all possibilities to add binary operators (not unary) +, -, or * between the d
阅读全文
摘要:Given A binary Tree, how do you remove all the half nodes (which has only one child)? Note leaves should not be touched as they have both children as
阅读全文
摘要:Given a digit string excluded 01, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on
阅读全文
摘要:Given a list of numbers with duplicate number in it. Find all unique permutations. Have you met this question in a real interview? Yes Given a list of
阅读全文
摘要:Given a list of numbers, return all possible permutations. You can assume that there is no duplicate numbers in the list. Given a list of numbers, ret
阅读全文
摘要:Given n friends, each one can remain single or can be paired up with some other friend. Each friend can be paired only once. Find out the total number
阅读全文
摘要:Given a list of Connections, which is the Connection class (the city name at both ends of the edge and a cost between them), find some edges, connect
阅读全文
摘要:Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'. A region is captured by flipping all 'O''s into 'X''s in that surround
阅读全文
摘要:A non-negative numbers can be regarded as product of its factors.Write a function that takes an integer n and return all possible combinations of its
阅读全文
摘要:You are given a m x n 2D grid initialized with these three possible values. -1 - A wall or an obstacle.0 - A gate.INF - Infinity means an empty room.
阅读全文
摘要:Given a set of n nuts of different sizes and n bolts of different sizes. There is a one-one mapping between nuts and bolts. Comparison of a nut to ano
阅读全文
摘要:The code base version is an integer start from 1 to n. One day, someone committed a bad version in the code case, so it caused this version and the fo
阅读全文
摘要:Calculate the (a^n) % b where a, b and n are all 32bit integers. Calculate the (a^n) % b where a, b and n are all 32bit integers. Calculate the (a^n)
阅读全文
摘要:The diameter of a tree (sometimes called the width) is the number of nodes on the longest path between two leaves in the tree. The diagram below shows
阅读全文
摘要:Given a binary tree with each node having one extra field of nextRight. nextRight points to the next right node of the same level. Initially all nodes
阅读全文
摘要:Given a Binary Tree, find if there exist edge whose removal creates two trees of equal size. Examples: To find whether such an edge exists, we need to
阅读全文
摘要:Given a sorted array of n integers, find the starting and ending position of a given target value. If the target is not found in the array, return [-1
阅读全文
摘要:Given a binary search tree (See Definition) and a node in it, find the in-order successor of that node in the BST. If the given node has no in-order s
阅读全文
摘要:Given a binary tree where all the right nodes are either leaf nodes with a sibling (a left node that shares the same parent node) or empty, flip it up
阅读全文
摘要:Given a binary tree, collect a tree's nodes as if you were doing this: Collect and remove all leaves, repeat until the tree is empty. Have you met thi
阅读全文
摘要:Given a binary tree, return the vertical order traversal of its nodes' values. (ie, from top to bottom, column by column). If two nodes are in the sam
阅读全文
摘要:Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all
阅读全文
摘要:Given a binary tree, check whether it is a mirror of itself using both recursion and iterative approach. Examples: Solution 1. Recursion For two trees
阅读全文
摘要:Given a Binary Tree, extract all leaves of it in a Doubly Linked List (DLL). Note that the DLL need to be created in-place. Assume that the node struc
阅读全文
摘要:Consider a game where a player can score 3 or 5 or 10 points in a move. Given a total score n, find the number of ways to reach the given score. Examp
阅读全文
摘要:Given a 2D matrix of integers, find maximum sum rectangle in this matrix. Brute force solution of enumerating all possible submatrix then check their
阅读全文
摘要:Given a 2D matrix of 0s and 1s, find maximum size rectangle of all 1s in this matrix. Brute force solution is very inefficient. A better solution is t
阅读全文
摘要: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 hist
阅读全文
摘要:You are given n pairs of numbers. In every pair, the first number is always smaller than the second number. A pair (c, d) can follow another pair (a,
阅读全文

浙公网安备 33010602011771号