[LeetCode] 438. Find All Anagrams in a String [滑动窗口]

2018-10-05
阅读 4 分钟
2.2k
Given a string s and a non-empty string p, find all the start indices of p's anagrams in s.

[LeetCode] 232. 225 Implement Queue/Stack using Stacks/Queues

2018-10-05
阅读 4 分钟
2.6k
push(x) -- Push element x to the back of queue.pop() -- Removes the element from in front of queue.peek() -- Get the front element.empty() -- Return whether the queue is empty.Example:

[LeetCode] BST Series #98 #99 #109 #173 #270

2018-10-05
阅读 2 分钟
1.6k
Given a binary tree, determine if it is a valid binary search tree (BST).

[LeetCode] 635. Design Log Storage System

2018-10-04
阅读 4 分钟
3.3k
You are given several logs that each log contains a unique id and timestamp. Timestamp is a string that has the following format: Year:Month:Day:Hour:Minute:Second, for example, 2017:01:01:23:59:59. All domains are zero-padded decimal numbers.

[LeetCode] 381. Insert Delete GetRandom

2018-10-03
阅读 3 分钟
1.6k
Design a data structure that supports all following operations in average O(1) time.

[LeetCode] 380. Insert Delete GetRandom O(1)

2018-10-03
阅读 2 分钟
1.8k
Design a data structure that supports all following operations in average O(1) time.

[LeetCode] 305. Number of Islands II

2018-10-03
阅读 5 分钟
5.1k
A 2d grid map of m rows and n columns is initially filled with water. We may perform an addLand operation which turns the water at position (row, col) into a land. Given a list of positions to operate, count the number of islands after each addLand operation. An island is surrounded by water and ...

[LeetCode] 482. License Key Formatting

2018-10-02
阅读 2 分钟
1.5k
You are given a license key represented as a string S which consists only alphanumeric character and dashes. The string is separated into N+1 groups by N dashes.

[LeetCode] 429. N-ary Tree Level Order Traversal (vs. LC102)

2018-10-02
阅读 2 分钟
2.6k
Given an n-ary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).

[LeetCode] 590. N-ary Tree Postorder Traversal (vs. LC145)

2018-10-02
阅读 3 分钟
2.4k
Given an n-ary tree, return the postorder traversal of its nodes' values.For example, given a 3-ary tree:Return its postorder traversal as: [5,6,3,2,4,1].Note: Recursive solution is trivial, could you do it iteratively?

[LeetCode] 589. N-ary Tree Preorder Traversal (vs. LC144)

2018-10-02
阅读 3 分钟
2.8k
Given an n-ary tree, return the preorder traversal of its nodes' values.For example, given a 3-ary tree:Return its preorder traversal as: [1,3,5,6,2,4].Note: Recursive solution is trivial, could you do it iteratively?

[LeetCode] 559. Maximum Depth of N-ary Tree

2018-10-02
阅读 1 分钟
3k
The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.

[LeetCode] 143. Reorder List

2018-10-01
阅读 2 分钟
1.5k
Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…

[LeetCode] 148. Sort List

2018-10-01
阅读 2 分钟
1.5k
Sort a linked list in O(n log n) time using constant space complexity.

[LeetCode] 383. Ransom Note

2018-09-30
阅读 1 分钟
1.1k
Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom note can be constructed from the magazines ; otherwise, it will return false.

[LeetCode] 289. Game of Life

2018-09-28
阅读 3 分钟
1.6k
According to the Wikipedia's article: "The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970."

[LeetCode] 22. Generate Parentheses

2018-09-27
阅读 1 分钟
1.8k
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.

[LeetCode] 415. Add Strings

2018-09-26
阅读 2 分钟
2k
Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2.

[LeetCode] 824. Goat Latin

2018-09-26
阅读 2 分钟
2k
A sentence S is given, composed of words separated by spaces. Each word consists of lowercase and uppercase letters only.

[LeetCode] 253. Meeting Rooms II

2018-09-26
阅读 2 分钟
3.7k
Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si < ei), find the minimum number of conference rooms required.

[LeetCode] 543. Diameter of Binary Tree

2018-09-26
阅读 1 分钟
1.6k
Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path may or may not pass through the root.

[LeetCode] 246. Strobogrammatic Number

2018-09-25
阅读 1 分钟
1.6k
A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down).

[LeetCode] 896. Monotonic Array

2018-09-25
阅读 2 分钟
2.3k
An array is monotonic if it is either monotone increasing or monotone decreasing.

[LeetCode] 451. Sort Characters By Frequency

2018-09-24
阅读 2 分钟
2.4k
Given a string, sort it in decreasing order based on the frequency of characters.

[LeetCode] 611. Valid Triangle Number

2018-09-24
阅读 1 分钟
2.3k
Given an array consists of non-negative integers, your task is to count the number of triplets chosen from the array that can make triangles if we take them as side lengths of a triangle.Example 1:Input: [2,2,3,4]Output: 3Explanation:Valid combinations are: 2,3,4 (using the first 2)2,3,4 (using t...

[LeetCode] 37. Sudoku Solver

2018-09-24
阅读 2 分钟
2.3k
Each of the digits 1-9 must occur exactly once in each row.Each of the digits 1-9 must occur exactly once in each column.Each of the the digits 1-9 must occur exactly once in each of the 9 3x3 sub-boxes of the grid.Empty cells are indicated by the character '.'.

[LeetCode] 32. Longest Valid Parentheses

2018-09-24
阅读 2 分钟
2.2k
Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.

[LeetCode] 441. Arranging Coins

2018-09-23
阅读 1 分钟
1.4k
You have a total of n coins that you want to form in a staircase shape, where every k-th row must have exactly k coins.

[LeetCode] 507. Perfect Number

2018-09-21
阅读 1 分钟
1.3k
We define the Perfect Number is a positive integer that is equal to the sum of all its positive divisors except itself.

[LeetCode] 297. Serialize and Deserialize Binary Tree

2018-09-20
阅读 2 分钟
1.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.