[LeetCode] 814. Binary Tree Pruning

2018-10-29
阅读 2 分钟
1.3k
We are given the head node root of a binary tree, where additionally every node's value is either a 0 or a 1.

[LeetCode] 371. Sum of Two Integers

2018-10-29
阅读 1 分钟
1.6k
Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -.

[LeetCode] 557. Reverse Words in a String III

2018-10-29
阅读 2 分钟
1.8k
Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.

[LeetCode] 170. Two Sum III - Data structure design

2018-10-28
阅读 2 分钟
2k
Design and implement a TwoSum class. It should support the following operations: add and find.

[LeetCode] 567. Permutation in String

2018-10-28
阅读 2 分钟
1.9k
Given two strings s1 and s2, write a function to return true if s2 contains the permutation of s1. In other words, one of the first string's permutations is the substring of the second string.Example 1:

[LeetCode] 428. Serialize and Deserialize N-ary Tree

2018-10-25
阅读 3 分钟
5.3k
Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connection link to be reconstructed later in the same or another computer environment.

[LeetCode] 251. Flatten 2D Vector

2018-10-25
阅读 1 分钟
3.1k
Follow up:As an added challenge, try to code it using only iterators in C++ or iterators in Java.

[LeetCode] 124. Binary Tree Maximum Path Sum

2018-10-25
阅读 1 分钟
1.8k
For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connections. The path must contain at least one node and does not need to go through the root.

[LeetCode] 29. Divide Two Integers

2018-10-25
阅读 2 分钟
2.5k
Given two integers dividend and divisor, divide two integers without using multiplication, division and mod operator.

[LeetCode] 689. Maximum Sum of 3 Non-Overlapping Subarrays

2018-10-24
阅读 3 分钟
2.1k
In a given array nums of positive integers, find three non-overlapping subarrays with maximum sum.

[LeetCode] 560. Subarray Sum Equals K

2018-10-24
阅读 1 分钟
2.6k
Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k.

[LeetCode] 621. Task Scheduler

2018-10-23
阅读 2 分钟
2.7k
Given a char array representing tasks CPU need to do. It contains capital letters A to Z where different letters represent different tasks.Tasks could be done without original order. Each task could be done in one interval. For each interval, CPU could finish one task or just be idle.

[LeetCode] 10. Regular Expression Matching

2018-10-22
阅读 2 分钟
2.5k
Given an input string (s) and a pattern (p), implement regular expression matching with support for '.' and '*'.

[LeetCode] 426. Convert BST to Sorted Doubly Linked List

2018-10-22
阅读 3 分钟
5.5k
Convert a BST to a sorted circular doubly-linked list in-place. Think of the left and right pointers as synonymous to the previous and next pointers in a doubly-linked list.

[LeetCode] 211. Add and Search Word - Data structure design

2018-10-22
阅读 2 分钟
1.4k
void addWord(word)bool search(word)search(word) can search a literal word or a regular expression string containing only letters a-z or .. A . means it can represent any one letter.

[LeetCode] 226. Invert Binary Tree

2018-10-22
阅读 2 分钟
1.7k
Trivia:This problem was inspired by this original tweet by Max Howell:

[LeetCode] 329. Longest Increasing Path in a Matrix

2018-10-17
阅读 2 分钟
2.9k
Given an integer matrix, find the length of the longest increasing path.

[LeetCode] 461. Hamming Distance

2018-10-17
阅读 1 分钟
1.4k
The Hamming distance between two integers is the number of positions at which the corresponding bits are different.

[LeetCode] 354. Russian Doll Envelopes

2018-10-17
阅读 2 分钟
2.3k
You have a number of envelopes with widths and heights given as a pair of integers (w, h). One envelope can fit into another if and only if both the width and height of one envelope is greater than the width and height of the other envelope.

[LeetCode] 674. Longest Continuous Increasing Subsequence

2018-10-09
阅读 2 分钟
1.7k
Given an unsorted array of integers, find the length of longest continuous increasing subsequence (subarray).

[LeetCode] 314. Binary Tree Vertical Order Traversal

2018-10-09
阅读 2 分钟
3.1k
Given a binary tree, return the vertical order traversal of its nodes' values. (ie, from top to bottom, column by column).

[LeetCode] 680. Valid Palindrome II

2018-10-09
阅读 1 分钟
2.2k
Given a non-empty string s, you may delete at most one character. Judge whether you can make it a palindrome.

[LeetCode] 893. Groups of Special-Equivalent Strings

2018-10-09
阅读 2 分钟
2.2k
Two strings S and T are special-equivalent if after any number of moves, S == T.

[LeetCode] 524. Longest Word in Dictionary through Deleting

2018-10-09
阅读 2 分钟
2.3k
Given a string and a string dictionary, find the longest string in the dictionary that can be formed by deleting some characters of the given string. If there are more than one possible results, return the longest word with the smallest lexicographical order. If there is no possible result, retur...

[LeetCode] 564. Find the Closest Palindrome

2018-10-08
阅读 2 分钟
2k
Given an integer n, find the closest integer (not including itself), which is a palindrome.

[LeetCode] 632. Smallest Range

2018-10-08
阅读 4 分钟
2.7k
You have k lists of sorted integers in ascending order. Find the smallest range that includes at least one number from each of the k lists.

[LeetCode] 359. Logger Rate Limiter

2018-10-07
阅读 3 分钟
2.2k
Problem {代码...} Solution #1: map saving earliest good time {代码...} Solution #2: remove obsolete messages by using a queue and a set {代码...}

[LeetCode] 362. Design Hit Counter

2018-10-07
阅读 2 分钟
2.9k
Design a hit counter which counts the number of hits received in the past 5 minutes.

[LeetCode] 254. Factor Combinations

2018-10-07
阅读 2 分钟
2.7k
8 = 2 x 2 x 2; = 2 x 4.Write a function that takes an integer n and return all possible combinations of its factors.

[LeetCode] 346. Moving Average from Data Stream

2018-10-05
阅读 1 分钟
2.7k
Given a stream of integers and a window size, calculate the moving average of all integers in the sliding window.