[LeetCode] 568. Maximum Vacation Days

2018-11-12
阅读 4 分钟
3.8k
LeetCode wants to give one of its best employees the option to travel among N cities to collect algorithm problems. But all work and no play makes Jack a dull boy, you could take vacations in some particular cities and weeks. Your job is to schedule the traveling to maximize the number of vacatio...

[LeetCode] 528. Random Pick with Weight

2018-11-12
阅读 2 分钟
4.2k
Given an array w of positive integers, where w[i] describes the weight of index i, write a function pickIndex which randomly picks an index in proportion to its weight.

[LeetCode] 642. Design Search Autocomplete System

2018-11-11
阅读 5 分钟
5.8k
Design a search autocomplete system for a search engine. Users may input a sentence (at least one word and end with a special character '#'). For each character they type except '#', you need to return the top 3 historical hot sentences that have prefix the same as the part of sentence already ty...

[LeetCode] 745. Prefix and Suffix Search

2018-11-11
阅读 2 分钟
2.6k
Design a class WordFilter that supports one function, WordFilter.f(String prefix, String suffix). It will return the word with given prefix and suffix with maximum weight. If no word exists, return -1.

[LeetCode] 606. Construct String from Binary Tree

2018-11-09
阅读 2 分钟
2k
You need to construct a string consists of parenthesis and integers from a binary tree with the preorder traversing way.

[LeetCode] 652. Find Duplicate Subtrees

2018-11-09
阅读 1 分钟
2.2k
Given a binary tree, return all duplicate subtrees. For each kind of duplicate subtrees, you only need to return the root node of any one of them.

[LeetCode] 640. Solve the Equation

2018-11-09
阅读 2 分钟
2.7k
Solve a given equation and return the value of x in the form of string "x=#value". The equation contains only '+', '-' operation, the variable x and its coefficient.

[LeetCode] 628. Maximum Product of Three Numbers

2018-11-08
阅读 2 分钟
1.6k
Given an integer array, find three numbers whose product is maximum and output the maximum product.

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

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

[LeetCode] 917. Reverse Only Letters

2018-11-08
阅读 1 分钟
2.7k
Given a string S, return the "reversed" string where all characters that are not a letter stay in the same place, and all letters reverse their positions.

[LeetCode] 204. Count Primes

2018-11-08
阅读 1 分钟
2.1k
Input: 10Output: 4Explanation: There are 4 prime numbers less than 10, they are 2, 3, 5, 7.

[LeetCode] 669. Trim a Binary Search Tree

2018-11-08
阅读 2 分钟
2.3k
Given a binary search tree and the lowest and highest boundaries as L and R, trim the tree so that all its elements lies in [L, R] (R >= L). You might need to change the root of the tree, so the result should return the new root of the trimmed binary search tree.

[LeetCode] 168. Excel Sheet Column Title

2018-11-08
阅读 1 分钟
1.5k
Given a positive integer, return its corresponding column title as appear in an Excel sheet.

[LeetCode] 403. Frog Jump

2018-11-08
阅读 2 分钟
2.4k
A frog is crossing a river. The river is divided into x units and at each unit there may or may not exist a stone. The frog can jump on a stone, but it must not jump into the water.

[LeetCode] 266. Palindrome Permutation

2018-11-06
阅读 1 分钟
1.6k
Given a string, determine if a permutation of the string could form a palindrome.

[LeetCode] 171. Excel Sheet Column Number

2018-11-06
阅读 1 分钟
1.4k
Given a column title as appear in an Excel sheet, return its corresponding column number.

[LeetCode] 166. Fraction to Recurring Decimal

2018-11-06
阅读 2 分钟
1.5k
Given two integers representing the numerator and denominator of a fraction, return the fraction in string format.

[LeetCode] 322. Coin Change

2018-11-05
阅读 1 分钟
1.9k
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] 333. Largest BST Subtree

2018-11-05
阅读 2 分钟
3.6k
Given a binary tree, find the largest subtree which is a Binary Search Tree (BST), where largest means subtree with largest number of nodes in it.

[LeetCode] 450. Delete Node in a BST

2018-11-04
阅读 2 分钟
3k
Given a root node reference of a BST and a key, delete the node with the given key in the BST. Return the root node reference (possibly updated) of the BST.

[LeetCode] 388. Longest Absolute File Path

2018-11-04
阅读 2 分钟
1.4k
Suppose we abstract our file system by a string in the following manner:

[LeetCode] 118. Pascal's Triangle

2018-10-31
阅读 1 分钟
1.7k
Given a non-negative integer numRows, generate the first numRows of Pascal's triangle.

[LeetCode] 849. Maximize Distance to Closest Person

2018-10-31
阅读 2 分钟
2.2k
In a row of seats, 1 represents a person sitting in that seat, and 0 represents that the seat is empty.

[LeetCode] 205. Isomorphic Strings

2018-10-31
阅读 2 分钟
2.8k
Two strings are isomorphic if the characters in s can be replaced to get t.

[LintCode] 604. Design Compressed String Iterator

2018-10-31
阅读 2 分钟
2.2k
Design and implement a data structure for a compressed string iterator. It should support the following operations: next and hasNext.

[LeetCode] 686. Repeated String Match

2018-10-31
阅读 1 分钟
2.2k
Given two strings A and B, find the minimum number of times A has to be repeated such that B is a substring of it. If no such solution, return -1.

[LeetCode] 681. Next Closest Time

2018-10-31
阅读 2 分钟
3.1k
Given a time represented in the format "HH:MM", form the next closest time by reusing the current digits. There is no limit on how many times a digit can be reused.

[LeetCode] 844. Backspace String Compare

2018-10-30
阅读 2 分钟
2k
Given two strings S and T, return if they are equal when both are typed into empty text editors. # means a backspace character.

[LeetCode] 904. Fruit Into Baskets

2018-10-30
阅读 2 分钟
3.5k
You start at any tree of your choice, then repeatedly perform the following steps:

[LeetCode] 819. Most Common Word

2018-10-30
阅读 2 分钟
1.2k
Given a paragraph and a list of banned words, return the most frequent word that is not in the list of banned words. It is guaranteed there is at least one word that isn't banned, and that the answer is unique.