[LeetCode] 958. Check Completeness of a Binary Tree

2019-01-14
阅读 1 分钟
2.1k
Definition of a complete binary tree from Wikipedia:In a complete binary tree every level, except possibly the last, is completely filled, and all nodes in the last level are as far left as possible. It can have between 1 and 2^h nodes inclusive at the last level h.

[LeetCode] 223. Rectangle Area

2019-01-14
阅读 1 分钟
1.5k
Find the total area covered by two rectilinear rectangles in a 2D plane.

[LeetCode] 448. Find All Numbers Disappeared in an Array

2019-01-14
阅读 1 分钟
1.5k
Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.

[LeetCode] 442. Find All Duplicates in an Array

2019-01-14
阅读 1 分钟
1.6k
Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.

[LeetCode] 328. Odd Even Linked List

2019-01-14
阅读 1 分钟
1.7k
Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes.

[LeetCode] 937. Reorder Log Files

2019-01-14
阅读 2 分钟
2.1k
You have an array of logs. Each log is a space delimited string of words.

[LeetCode] 84. Largest Rectangle in Histogram

2019-01-14
阅读 2 分钟
1.6k
Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram.

[LeetCode] 287. Find the Duplicate Number

2019-01-14
阅读 2 分钟
1.4k
Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate number, find the duplicate one.

[LeetCode] 165. Compare Version Numbers

2019-01-14
阅读 2 分钟
1.3k
Compare two version numbers version1 and version2.If version1 > version2 return 1; if version1 < version2 return -1;otherwise return 0.

[LeetCode] 545. Boundary of Binary Tree

2019-01-14
阅读 3 分钟
1.8k
Given a binary tree, return the values of its boundary in anti-clockwise direction starting from root. Boundary includes left boundary, leaves, and right boundary in order without duplicate nodes.

[LeetCode] 59. Spiral Matrix II

2019-01-14
阅读 1 分钟
1.4k
Given a positive integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.

[LeetCode] 605. Can Place Flowers

2018-12-31
阅读 2 分钟
1.7k
Suppose you have a long flowerbed in which some of the plots are planted and some are not. However, flowers cannot be planted in adjacent plots - they would compete for water and both would die.

[LeetCode] 867. Transpose Matrix

2018-12-31
阅读 1 分钟
1.8k
The transpose of a matrix is the matrix flipped over it's main diagonal, switching the row and column indices of the matrix.

[LeetCode] 876. Middle of the Linked List

2018-12-31
阅读 2 分钟
1.9k
Given a non-empty, singly linked list with head node head, return a middle node of linked list.

[LeetCode] 475. Heaters

2018-12-31
阅读 2 分钟
1.5k
Winter is coming! Your first job during the contest is to design a standard heater with fixed warm radius to warm all the houses.

[LeetCode] 617. Merge Two Binary Trees

2018-12-31
阅读 2 分钟
2k
Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not.

[LeetCode] 905. Sort Array By Parity

2018-12-31
阅读 1 分钟
1.6k
Given an array A of non-negative integers, return an array consisting of all the even elements of A, followed by all the odd elements of A.

[LeetCode] 709. To Lower Case

2018-12-31
阅读 1 分钟
2.5k
Implement function ToLowerCase() that has a string parameter str, and returns the same string in lowercase.

[LeetCode] 61. Rotate List

2018-12-30
阅读 2 分钟
1.7k
Given a linked list, rotate the list to the right by k places, where k is non-negative.

[LeetCode] 51. N-Queens

2018-12-30
阅读 2 分钟
2.3k
The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.

[LeetCode] 97. Interleaving String

2018-12-30
阅读 1 分钟
1.3k
Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.

[LeetCode] 249. Group Shifted Strings

2018-12-30
阅读 2 分钟
2.1k
Given a string, we can "shift" each of its letter to its successive letter, for example: "abc" -> "bcd". We can keep "shifting" which forms the sequence:

[LeetCode] 332. Reconstruct Itinerary

2018-12-30
阅读 2 分钟
1.5k
Given a list of airline tickets represented by pairs of departure and arrival airports [from, to], reconstruct the itinerary in order. All of the tickets belong to a man who departs from JFK. Thus, the itinerary must begin with JFK.

[LeetCode] 741. Cherry Pickup

2018-12-29
阅读 3 分钟
2.3k
In a N x N grid representing a field of cherries, each cell is one of three possible integers.

[LeetCode] 417. Pacific Atlantic Water Flow

2018-12-28
阅读 2 分钟
2.2k
Given an m x n matrix of non-negative integers representing the height of each unit cell in a continent, the "Pacific ocean" touches the left and top edges of the matrix and the "Atlantic ocean" touches the right and bottom edges.

[LeetCode] 364. Nested List Weight Sum II

2018-12-28
阅读 3 分钟
2.7k
Given a nested list of integers, return the sum of all integers in the list weighted by their depth.

[LeetCode] 767. Reorganize String

2018-12-27
阅读 2 分钟
2.1k
Given a string S, check if the letters can be rearranged so that two characters that are adjacent to each other are not the same.

[LeetCode] 115. Distinct Subsequences

2018-12-26
阅读 2 分钟
1.6k
Given a string S and a string T, count the number of distinct subsequences of S which equals T.

[LeetCode] 181. Employees Earning More Than Their Managers

2018-12-26
阅读 1 分钟
1.1k
The Employee table holds all employees including their managers. Every employee has an Id, and there is also a column for the manager Id.

[LeetCode] 402. Remove K Digits

2018-12-26
阅读 2 分钟
1.9k
Given a non-negative integer num represented as a string, remove k digits from the number so that the new number is the smallest possible.