[LeetCode C++实现]238. Product of Array Except Self

Given an array nums of n integers where n > 1, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i].

Example:

Input:

Output:

Constraint: It's guaranteed that the product of the elements of any prefix or suffix of the array......

[LeetCode C++实现]105. Construct Binary Tree

Given preorder and inorder traversal of a tree, construct the binary tree.

Note:

You may assume that duplicates do not exist in the tree.

For example, given

preorder = [3,9,20,15,7]

inorder = [9,3,15,20,7]

Return the following binary tree:

3

/ \

9 20

/ \

15 7

[LeetCode C++实现]53. Maximum Subarray

Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.

Example:

Input: [-2,1,-3,4,-1,2,1,-5,4],

Output: 6

Explanation: [4,-1,2,1] has the largest sum = 6.

[LeetCode C++实现]124. Binary Tree Maximum Path

Given a non-empty binary tree, find the maximum path sum.

For this problem, a path is defined as any sequence of nodes ......

[LeetCode C++实现]78.Subsets

Given a set of distinct integers, nums, return all possible subsets (the power set).

Note: The solution set must not contain duplicate subsets.

Example:

Input: nums = [1,2,3]

Output:

[

[3],

[1],

[......

[LeetCode C++实现]347. Top K Frequent Elements

Given a non-empty array of integers, return the k most frequent elements.

Example 1:

Input: nums = [1,1,1,2,2,3], k = 2

Output:

Example 2:

Input: nums = [1], k = 1

Output:

Note:

You may assume k is always valid, 1 ≤ k ≤ number of unique elements.

[LeetCode C++实现]22.Generate Parentheses

Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.

For example, given n = 3, a solution set is:

[

"((()))",

"(()())",

"(())()",

"()(())",

"()()()"

]

[LeetCode C++实现]406. Queue Reconstruction by Height

[[7,0], [4,4], [7,1], [5,0], ......

[LeetCode C++实现]46.Permutations

46.Permutations

next_permutation

class Solution {

public:

vector<vector<int> > permute(vector<int> &num) {

vector<vector<int> > ans;

sort(num.begin(), num......

[LeetCode C++实现]86.Partition List

86.Partition List

/**

* struct ListNode {

* int val;

* ListNode *next;

* ListNode(int x) : val(x), next(NULL) {}

* };

*/

class Solution {

public:

ListNode......