[LeetCode] 8. String to Integer (atoi)

2016-05-23
阅读 2 分钟
2.3k
If the correct value is out of the range of representable values, INT_MAX (2147483647) or INT_MIN (-2147483648) is returned.

[LintCode/LeetCode] Decode Ways [String to Integer]

2016-05-23
阅读 2 分钟
2.6k
A message containing letters from A-Z is being encoded to numbers using the following mapping:

[LintCode] Compare Strings

2016-05-21
阅读 1 分钟
2.2k
Compare two strings A and B, determine whether A contains all of the characters in B.

[LeetCode] 4Sum & 4Sum II

2016-05-21
阅读 4 分钟
2k
Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target?

[LintCode/LeetCode] 3Sum Closest

2016-05-21
阅读 1 分钟
2.3k
Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers.

[LintCode/LeetCode] 3Sum

2016-05-21
阅读 3 分钟
2.4k
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.

[LeetCode] 52. N-Queens II

2016-05-18
阅读 2 分钟
3.6k
The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.

[LintCode/LeetCode] Search Insert Position

2016-05-18
阅读 1 分钟
2.4k
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.

[LintCode/LeetCode] Search for a Range [左右边界法/一次循环法]

2016-05-18
阅读 2 分钟
5.1k
Given a sorted array of n integers, find the starting and ending position of a given target value.

[LintCode/LeetCode] Search in Rotated Sorted Array I & II

2016-05-17
阅读 3 分钟
2.6k
Suppose a sorted array is rotated at some pivot unknown to you beforehand.

[LintCode/LeetCode] Merge Sorted Array

2016-05-17
阅读 2 分钟
2.5k
Given two sorted integer arrays A and B, merge B into A as one sorted array.

[LintCode/LeetCode] Median of two Sorted Arrays

2016-05-17
阅读 3 分钟
2.7k
There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays.

[LintCode/LeetCode] Binary Tree Preorder Traversal

2016-05-16
阅读 2 分钟
2.1k
Given a binary tree, return the preorder traversal of its nodes' values.

[LintCode/LeetCode] Binary Tree InOrder Traversal

2016-05-16
阅读 2 分钟
2.1k
Given a binary tree, return the inorder traversal of its nodes' values.

[LintCode/LeetCode] Binary Tree Zigzag Level Order Traversal

2016-05-15
阅读 2 分钟
2.6k
Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between).

[LintCode/LeetCode] Construct Binary Tree from Traversal

2016-05-14
阅读 4 分钟
2.3k
Given preorder and inorder traversal of a tree, construct the binary tree.

[LC总结] 排序 Median [QuickSort] Sort Integers II

2016-05-01
阅读 4 分钟
4.1k
Given a binary search tree and a new tree node, insert the node into the tree. You should keep the tree still be a valid binary search tree.Given a unsorted array with integers, find the median of it.

[LintCode] Insert Node in a Binary Search Tree

2016-04-30
阅读 1 分钟
2.5k
Given a binary search tree and a new tree node, insert the node into the tree. You should keep the tree still be a valid binary search tree.

[LintCode/LeetCode] Single Number I & II [位运算]

2016-04-30
阅读 2 分钟
3.5k
Given 2*n + 1 numbers, every numbers occurs twice except one, find it.

[LintCode/LeetCode] Single Number III

2016-04-30
阅读 1 分钟
2.1k
Given 2*n + 2 numbers, every numbers occurs twice except two, find them.

[LintCode] Remove Node in Binary Search Tree [理解BST]

2016-04-29
阅读 2 分钟
3.8k
Given a root of Binary Search Tree with unique value for each node. Remove the node with given value. If there is no such a node with given value in the binary search tree, do nothing. You should keep the tree still a binary search tree after removal.

[LintCode] Binary Search Tree Iterator

2016-04-29
阅读 2 分钟
2.5k
Design an iterator over a binary search tree with the following rules:

[LintCode/LeetCode] Lowest Common Ancestor of BST/Binary Tree

2016-04-29
阅读 2 分钟
2.2k
Given the root and two nodes in a Binary Tree. Find the lowest common ancestor(LCA) of the two nodes.

[LintCode/LeetCode] Balanced Binary Tree

2016-04-29
阅读 1 分钟
2.3k
For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never differ by more than 1.

[LintCode/LeetCode] Binary Tree Maximum Path Sum

2016-04-29
阅读 2 分钟
2.2k
Problem Given a binary tree, find the maximum path sum. The path may start and end at any node in the tree. Example Given the below binary tree: {代码...} return 6. Note 调用helper函数更新路径和的最大值res,而helper函数本身需要递归,返回的是单边路径和single。这里需要注意:对于拱形路径和arch,从左...

[LintCode/LeetCode] House Robber III

2016-04-29
阅读 2 分钟
2.3k
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, the smart thief realized that "all houses in this place forms a binary tree". It will automatic...

[LintCode/LeetCode] House Robber II

2016-04-29
阅读 2 分钟
2k
After robbing those houses on that street, the thief has found himself a new place for his thievery so that he will not get too much attention. This time, all houses at this place are arranged in a circle. That means the first house is the neighbor of the last one. Meanwhile, the security system ...

[LintCode/LeetCode] Validate Binary Search Tree

2016-04-28
阅读 2 分钟
3.2k
Given a binary tree, determine if it is a valid binary search tree (BST).

[LintCode/LeetCode] Partition List

2016-04-28
阅读 2 分钟
2.1k
Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.

[LintCode/LeetCode] Maximum Depth of Binary Tree

2016-04-28
阅读 1 分钟
2.5k
The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.