LeetCode 342. Power of Four

2019-04-08
阅读 1 分钟
1.1k
Given an integer (signed 32 bits), write a function to check whether it is a power of 4.

LeetCode 341. Flatten Nested List Iterator

2019-04-08
阅读 2 分钟
1.6k
Each element is either an integer, or a list -- whose elements may also be integers or other lists.

LeetCode 337. House Robber III

2019-04-07
阅读 2 分钟
1.1k
The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the "root." Besides the root, each house has one and only one parent house. After a tour, the smart thief realized that "all houses in this place forms a binary tree". It will automatic...

LeetCode 336. Palindrome Pairs

2019-04-07
阅读 2 分钟
1.5k
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.

LeetCode 334. Increasing Triplet Subsequence

2019-03-28
阅读 2 分钟
1.2k
Given an unsorted array return whether an increasing subsequence of length 3 exists or not in the array.

LeetCode 331. Verify Preorder Serialization of a Binary Tree

2019-03-17
阅读 3 分钟
1.4k
One way to serialize a binary tree is to use pre-order traversal. When we encounter a non-null node, we record the node's value. If it is a null node, we record using a sentinel value such as #.

LeetCode 330. Patching Array

2019-03-14
阅读 2 分钟
1.2k
Given a sorted positive integer array nums and an integer n, add/patch elements to the array such that any number in range [1, n] inclusive can be formed by the sum of some elements in the array. Return the minimum number of patches required.

LeetCode 329. Longest Increasing Path in a Matrix

2019-03-07
阅读 2 分钟
1.5k
Given an integer matrix, find the length of the longest increasing path.

LeetCode 328. Odd Even Linked List

2019-03-03
阅读 3 分钟
1.5k
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 322. Coin Change

2019-03-01
阅读 3 分钟
1.3k
You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount of money cannot be made up by any combination of the coins, return -1.

LeetCode 321. Create Maximum Number

2019-02-26
阅读 3 分钟
1.4k
Given two arrays of length m and n with digits 0-9 representing two numbers. Create the maximum number of length k <= m + n from digits of the two. The relative order of the digits from the same array must be preserved. Return an array of the k digits.

LeetCode 319. Bulb Switcher

2019-02-24
阅读 2 分钟
1.6k
There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every second bulb. On the third round, you toggle every third bulb (turning on if it's off or turning off if it's on). For the i-th round, you toggle every i bulb. For the n-th round, you only toggle the...

LeetCode 318. Maximum Product of Word Lengths

2019-02-23
阅读 3 分钟
1.6k
Given a string array words, find the maximum value of length(word[i]) * length(word[j]) where the two words do not share common letters. You may assume that each word will contain only lower case letters. If no such two words exist, return 0.

LeetCode 316. Remove Duplicate Letters

2019-02-22
阅读 3 分钟
1.3k
Given a string which contains only lowercase letters, remove duplicate letters so that every letter appear once and only once. You must make sure your result is the smallest in lexicographical order among all possible results.

LeetCode 315. Count of Smaller Numbers After Self

2019-02-21
阅读 4 分钟
1.3k
You are given an integer array nums and you have to return a new counts array. The counts array has the property where counts[i] is the number of smaller elements to the right of nums[i].

LeetCode 313. Super Ugly Number

2019-02-19
阅读 3 分钟
1.7k
Super ugly numbers are positive numbers whose all prime factors are in the given prime list primes of size k.

LeetCode 312. Burst Balloons

2019-02-18
阅读 3 分钟
1.7k
Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by array nums. You are asked to burst all the balloons. If the you burst balloon i you will get nums[left] nums[i] nums[right] coins. Here left and right are adjacent indices of i. After the burst, th...

LeetCode 310. Minimum Height Trees

2019-02-17
阅读 3 分钟
1.5k
For an undirected graph with tree characteristics, we can choose any node as the root. The result graph is then a rooted tree. Among all possible rooted trees, those with minimum height are called minimum height trees (MHTs). Given such a graph, write a function to find all the MHTs and return a ...

LeetCode 309. Best Time to Buy and Sell Stock with Cooldown

2019-02-13
阅读 2 分钟
1.8k
Say you have an array for which the ith element is the price of a given stock on day i.

LeetCode 306. Additive Number

2019-02-12
阅读 3 分钟
1.2k
A valid additive sequence should contain at least three numbers. Except for the first two numbers, each subsequent number in the sequence must be the sum of the preceding two.