[LeetCode] 239. Sliding Window Maximum

2018-11-20
阅读 2 分钟
2.2k
Given an array nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window moves right by one position. Return the max sliding window.

[LeetCode] 285. Inorder Successor in BST

2018-11-19
阅读 1 分钟
2.9k
Given a binary search tree and a node in it, find the in-order successor of that node in the BST.

[LeetCode] 776. Split BST

2018-11-19
阅读 2 分钟
4.2k
Given a Binary Search Tree (BST) with root node root, and a target value V, split the tree into two subtrees where one subtree has nodes that are all smaller or equal to the target value, while the other subtree has all nodes that are greater than the target value. It's not necessarily the case t...

[LeetCode] 435. Non-overlapping Intervals

2018-11-19
阅读 2 分钟
2k
Given a collection of intervals, find the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping.

[LeetCode] 291. Word Pattern II

2018-11-19
阅读 2 分钟
3.4k
Given a pattern and a string str, find if str follows the same pattern.

[LeetCode] 518. Coin Change 2

2018-11-19
阅读 2 分钟
2.7k
You are given coins of different denominations and a total amount of money. Write a function to compute the number of combinations that make up that amount. You may assume that you have infinite number of each kind of coin.

[LeetCode] 254. Factor Combinations

2018-11-19
阅读 2 分钟
1.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] 317. Shortest Distance from All Buildings

2018-11-18
阅读 3 分钟
3.3k
You want to build a house on an empty land which reaches all buildings in the shortest amount of distance. You can only move up, down, left and right. You are given a 2D grid of values 0, 1 or 2, where:

[LeetCode] 296. Best Meeting Point

2018-11-18
阅读 2 分钟
2.7k
A group of two or more people wants to meet and minimize the total travel distance. You are given a 2D grid of values 0 or 1, where each 1 marks the home of someone in the group. The distance is calculated using Manhattan Distance, where distance(p1, p2) = |p2.x - p1.x| + |p2.y - p1.y|.

[LeetCode] 304. Range Sum Query 2D - Immutable

2018-11-18
阅读 2 分钟
1.6k
Given a 2D matrix matrix, find the sum of the elements inside the rectangle defined by its upper left corner (row1, col1) and lower right corner (row2, col2).

[LeetCode] 230. Kth Smallest Element in a BST

2018-11-18
阅读 2 分钟
1.8k
Given a binary search tree, write a function kthSmallest to find the kth smallest element in it.

[LeetCode] 529. Minesweeper

2018-11-18
阅读 3 分钟
1.6k
You are given a 2D char matrix representing the game board. 'M' represents an unrevealed mine, 'E' represents an unrevealed empty square, 'B' represents a revealed blank square that has no adjacent (above, below, left, right, and all 4 diagonals) mines, digit ('1' to '8') represents how many mine...

[LeetCode] 526. Beautiful Arrangement

2018-11-18
阅读 2 分钟
1.9k
Suppose you have N integers from 1 to N. We define a beautiful arrangement as an array that is constructed by these N numbers successfully if one of the following is true for the ith position (1 <= i <= N) in this array:

[LeetCode] 457. Circular Array Loop

2018-11-17
阅读 2 分钟
3.4k
You are given an array of positive and negative integers. If a number n at an index is positive, then move forward n steps. Conversely, if it's negative (-n), move backward n steps. Assume the first element of the array is forward next to the last element, and the last element is backward next to...

[LeetCode] 119. Pascal's Triangle II

2018-11-17
阅读 1 分钟
1.4k
In Pascal's triangle, each number is the sum of the two numbers directly above it.

[LeetCode] 408. Valid Word Abbreviation

2018-11-17
阅读 2 分钟
2.6k
Given a non-empty string s and an abbreviation abbr, return whether the string matches with the given abbreviation.

[LeetCode] 733. Flood Fill

2018-11-16
阅读 2 分钟
1.2k
An image is represented by a 2-D array of integers, each integer representing the pixel value of the image (from 0 to 65535).

[LeetCode] 378. Kth Smallest Element in a Sorted Matrix

2018-11-16
阅读 2 分钟
2k
Given a n x n matrix where each of the rows and columns are sorted in ascending order, find the kth smallest element in the matrix.

[LeetCode] 695. Max Area of Island

2018-11-16
阅读 2 分钟
1.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] 384. Shuffle an Array

2018-11-16
阅读 2 分钟
2.7k
// Init an array with set 1, 2, and 3.int[] nums = {1,2,3};Solution solution = new Solution(nums);

[LeetCode] 9. Palindrome Number

2018-11-15
阅读 1 分钟
1.1k
Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward.

[LeetCode] 109. Convert Sorted List to Binary Search Tree

2018-11-15
阅读 1 分钟
2.7k
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.

[LeetCode] 678. Valid Parenthesis String

2018-11-15
阅读 2 分钟
1.6k
Given a string containing only three types of characters: '(', ')' and '*', write a function to check whether this string is valid. We define the validity of a string by these rules:

[LeetCode] 416. Partition Equal Subset Sum

2018-11-15
阅读 2 分钟
2.7k
Given a non-empty array containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both subsets is equal.

[LeetCode] 698. Partition to K Equal Sum Subsets

2018-11-14
阅读 1 分钟
2.8k
Given an array of integers nums and a positive integer k, find whether it's possible to divide this array into k non-empty subsets whose sums are all equal.

[LeetCode] 425. Word Squares

2018-11-14
阅读 3 分钟
3.6k
Given a set of words (without duplicates), find all word squares you can build from them.

[LeetCode] 530. Minimum Absolute Difference in BST

2018-11-13
阅读 2 分钟
2k
Given a binary search tree with non-negative values, find the minimum absolute difference between values of any two nodes.

[LeetCode] 212. Word Search II

2018-11-12
阅读 2 分钟
2.3k
Given a 2D board and a list of words from the dictionary, find all words in the board.

[LeetCode] 538. Convert BST to Greater Tree

2018-11-12
阅读 2 分钟
2.2k
Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all keys greater than the original key in BST.

[LeetCode] 399. Evaluate Division

2018-11-12
阅读 6 分钟
4k
Equations are given in the format A / B = k, where A and B are variables represented as strings, and k is a real number (floating point number). Given some queries, return the answers. If the answer does not exist, return -1.0.