Quantcast
Channel: 书影 - Entries for the tag leetcode
Browsing all 559 articles
Browse latest View live

[LeetCode]Largest Sum of Averages

题目描述:LeetCode 813. Largest Sum of AveragesWe partition a row of numbers A into at most K adjacent (non-empty) groups, then our score is the sum of the average of each group. What is the largest score...

View Article


[LeetCode]Bus Routes

题目描述:LeetCode 815. Bus RoutesWe have a list of bus routes. Each routes[i] is a bus route that the i-th bus repeats forever. For example if routes[0] = [1, 5, 7], this means that the first bus (0-th...

View Article


[LeetCode]Most Common Word

题目描述:LeetCode 819. Most Common WordGiven 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...

View Article

[LeetCode]Linked List Components

题目描述:LeetCode 817. Linked List ComponentsWe are given head, the head node of a linked list containing unique integer values.We are also given the list G, a subset of the values in the linked...

View Article

[LeetCode]Ambiguous Coordinates

题目描述:LeetCode 816. Ambiguous CoordinatesWe had some 2-dimensional coordinates, like "(1, 3)" or "(2, 0.5)".  Then, we removed all commas, decimal points, and spaces, and ended up with the string S....

View Article


[LeetCode]Shortest Distance to a Character

题目描述:LeetCode 821. Shortest Distance to a CharacterGiven a string S and a character C, return an array of integers representing the shortest distance from the character C in the string.Example 1:Input:...

View Article

[LeetCode]Card Flipping Game

题目描述:LeetCode 822. Card Flipping GameOn a table are N cards, with a positive integer printed on the front and back of each card (possibly different).We flip any number of cards, and after we choose one...

View Article

[LeetCode]Short Encoding of Words

题目描述:LeetCode 820. Short Encoding of WordsGiven a list of words, we may encode it by writing a reference string S and a list of indexes A.For example, if the list of words is ["time", "me", "bell"], we...

View Article


[LeetCode]Binary Trees With Factors

题目描述:LeetCode 823. Binary Trees With FactorsGiven an array of unique integers, each integer is strictly greater than 1.We make a binary tree using these integers and each number may be used for any...

View Article


[LeetCode]Goat Latin

题目描述:LeetCode 824. Goat LatinA sentence S is given, composed of words separated by spaces. Each word consists of lowercase and uppercase letters only.We would like to convert the sentence to "Goat...

View Article

[LeetCode]Friends Of Appropriate Ages

题目描述:LeetCode 825. Friends Of Appropriate AgesSome people will make friend requests. The list of their ages is given and ages[i] is the age of the ith person. Person A will NOT friend request person B...

View Article

[LeetCode]Most Profit Assigning Work

题目描述:LeetCode 826. Most Profit Assigning WorkWe have jobs: difficulty[i] is the difficulty of the ith job, and profit[i] is the profit of the ith job. Now we have some workers. worker[i] is the ability...

View Article

[LeetCode]Making A Large Island

题目描述:LeetCode 827. Making A Large IslandIn a 2D grid of 0s and 1s, we change at most one 0 to a 1.After, what is the size of the largest island? (An island is a 4-directionally connected group of...

View Article


[LeetCode]Positions of Large Groups

题目描述:LeetCode 830. Positions of Large GroupsIn a string S of lowercase letters, these letters form consecutive groups of the same character.For example, a string like S = "abbxxxxzyy" has the groups...

View Article

[LeetCode]Masking Personal Information

题目描述:LeetCode 831. Masking Personal InformationWe are given a personal information string S, which may represent either an email address or a phone number.We would like to mask this personal...

View Article


[LeetCode]Consecutive Numbers Sum

题目描述:LeetCode 829. Consecutive Numbers SumGiven a positive integer N, how many ways can we write it as a sum of consecutive positive integers?Example 1:Input: 5Output: 2Explanation: 5 = 5 = 2 +...

View Article

[LeetCode]Unique Letter String

题目描述:LeetCode 828. Unique Letter StringA character is unique in string S if it occurs exactly once in it.For example, in string S = "LETTER", the only unique characters are "L" and "R".Let's define...

View Article


[LeetCode]Backspace String Compare

题目描述:LeetCode 844. Backspace String CompareGiven two strings S and T, return if they are equal when both are typed into empty text editors. # means a backspace character.Example 1:Input: S = "ab#c", T...

View Article

[LeetCode]Hand of Straights

题目描述:LeetCode 846. Hand of StraightsAlice has a hand of cards, given as an array of integers.Now she wants to rearrange the cards into groups so that each group is size W, and consists of W consecutive...

View Article

[LeetCode]Longest Mountain in Array

题目描述:LeetCode 845. Longest Mountain in ArrayLet's call any (contiguous) subarray B (of A) a mountain if the following properties hold:B.length >= 3There exists some 0 < i < B.length - 1 such...

View Article
Browsing all 559 articles
Browse latest View live