[LeetCode] 548. Split Array with Equal Sum

2018-11-26
阅读 2 分钟
3.5k
Given an array with n integers, you need to find if there are triplets (i, j, k) which satisfies following conditions:

[LeetCode] 694. Number of Distinct Islands

2018-11-26
阅读 2 分钟
3.6k
Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of the grid are surrounded by water.

[LeetCode] 430. Flatten a Multilevel Doubly Linked List

2018-11-26
阅读 2 分钟
3.6k
You are given a doubly linked list which in addition to the next and previous pointers, it could have a child pointer, which may or may not point to a separate doubly linked list. These child lists may have one or more children of their own, and so on, to produce a multilevel data structure, as s...

[LeetCode] 116. Populating Next Right Pointers in Each Node

2018-11-26
阅读 2 分钟
2.2k
Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set to NULL.

[LeetCode] 339. Nested List Weight Sum

2018-11-26
阅读 2 分钟
2.5k
Given a nested list of integers, return the sum of all integers in the list weighted by their depth.

[LeetCode] 270. Closest Binary Search Tree Value

2018-11-25
阅读 1 分钟
2.1k
Given a non-empty binary search tree and a target value, find the value in the BST that is closest to the target.

[LeetCode] 797. All Paths From Source to Target

2018-11-25
阅读 2 分钟
2.5k
Given a directed, acyclic graph of N nodes. Find all possible paths from node 0 to node N-1, and return them in any order.

[LeetCode] 852. Peak Index in a Mountain Array

2018-11-25
阅读 2 分钟
1.7k
A.length >= 3There exists some 0 < i < A.length - 1 such that A[0] < A[1] < ... A[i-1] < A[i] > A[i+1] > ... > A[A.length - 1]Given an array that is definitely a mountain, return any i such that A[0] < A[1] < ... A[i-1] < A[i] > A[i+1] > ... > A[A.leng...

[LeetCode] 842. Split Array into Fibonacci Sequence

2018-11-25
阅读 2 分钟
2.5k
Given a string S of digits, such as S = "123456579", we can split it into a Fibonacci-like sequence [123, 456, 579].

[LeetCode] 404. Sum of Left Leaves

2018-11-24
阅读 2 分钟
1.7k
There are two left leaves in the binary tree, with values 9 and 15 respectively. Return 24.

[LeetCode] 724. Find Pivot Index

2018-11-24
阅读 2 分钟
1.2k
Given an array of integers nums, write a method that returns the "pivot" index of this array.

[LeetCode] 663. Equal Tree Partition

2018-11-24
阅读 2 分钟
2.7k
Given a binary tree with n nodes, your task is to check if it's possible to partition the tree to two trees which have the equal sum of values after removing exactly one edge on the original tree.

[LeetCode] 199. Binary Tree Right Side View

2018-11-24
阅读 2 分钟
1.7k
Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.

[LeetCode] 65. Valid Number

2018-11-24
阅读 2 分钟
1.6k
Note: It is intended for the problem statement to be ambiguous. You should gather all requirements up front before implementing one. However, here is a list of characters that can be in a valid decimal number:

[LeetCode] 671. Second Minimum Node In a Binary Tree

2018-11-24
阅读 2 分钟
2.2k
Given a non-empty special binary tree consisting of nodes with the non-negative value, where each node in this tree has exactly two or zero sub-node. If the node has two sub-nodes, then this node's value is the smaller value among its two sub-nodes.

[Design] 设计售票系统

2018-11-23
阅读 3 分钟
1.4k
The system should allow customers to search for movies and cinemas based on their locations (cities)

[LeetCode] 282. Expression Add Operators

2018-11-23
阅读 4 分钟
1.5k
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 digits so they evaluate to the target value.

[LeetCode] 158. Read N Characters Given Read4 II - Call multiple

2018-11-23
阅读 2 分钟
2.5k
The API: int read4(char *buf) reads 4 characters at a time from a file.

[LeetCode] 721. Accounts Merge

2018-11-23
阅读 4 分钟
3.9k
Given a list accounts, each element accounts[i] is a list of strings, where the first element accountsi is a name, and the rest of the elements are emails representing emails of the account.

[LeetCode] 382. Linked List Random Node

2018-11-23
阅读 2 分钟
1.6k
Given a singly linked list, return a random node's value from the linked list. Each node must have the same probability of being chosen.

[LeetCode] 575. Distribute Candies

2018-11-22
阅读 2 分钟
1.4k
Given an integer array with even length, where different numbers in this array represent different kinds of candies. Each number means one candy of the corresponding kind. You need to distribute these candies equally in number to brother and sister. Return the maximum number of kinds of candies t...

[LeetCode] 760. Find Anagram Mappings

2018-11-22
阅读 1 分钟
2.1k
Given two lists Aand B, and B is an anagram of A. B is an anagram of A means B is made by randomizing the order of the elements in A.

[LeetCode] 825. Friends Of Appropriate Ages

2018-11-22
阅读 2 分钟
1.8k
Some people will make friend requests. The list of their ages is given and ages[i] is the age of the ith person.

[LeetCode] 556. Next Greater Element III

2018-11-22
阅读 2 分钟
1.8k
Given a positive 32-bit integer n, you need to find the smallest 32-bit integer which has exactly the same digits existing in the integer n and is greater in value than n. If no such positive 32-bit integer exists, you need to return -1.

[LeetCode] 432. All O`one Data Structure

2018-11-21
阅读 4 分钟
3.6k
Inc(Key) - Inserts a new key with value 1. Or increments an existing key by 1. Key is guaranteed to be a non-empty string.Dec(Key) - If Key's value is 1, remove it from the data structure. Otherwise decrements an existing key by 1. If the key does not exist, this function does nothing. Key is gua...

[LeetCode] 398. Random Pick Index (Reservoir Sampling)

2018-11-21
阅读 3 分钟
2.1k
Given an array of integers with possible duplicates, randomly output the index of a given target number. You can assume that the given target number must exist in the array.

[LeetCode] 785. Is Graph Bipartite?

2018-11-20
阅读 3 分钟
2.6k
Given an undirected graph, return true if and only if it is bipartite.

[LeetCode] 523. Continuous Subarray Sum

2018-11-20
阅读 2 分钟
2.5k
Given a list of non-negative numbers and a target integer k, write a function to check if the array has a continuous subarray of size at least 2 that sums up to the multiple of k, that is, sums up to n*k where n is also an integer.

[LeetCode] 68. Text Justification

2018-11-20
阅读 4 分钟
1.4k
Given an array of words and a width maxWidth, format the text such that each line has exactly maxWidth characters and is fully (left and right) justified.

[LeetCode] 336. Palindrome Pairs

2018-11-20
阅读 3 分钟
2.8k
Given a list of unique words, find all pairs of distinct indices (i, j) in the given list, so that the concatenation of the two words, i.e. words[i] + words[j] is a palindrome.