- 博客(556)
- 资源 (2)
- 收藏
- 关注
原创 827. Making A Large Island
In 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 1s).Example 1:Input: [[1, 0], [0, 1]]...
2019-01-15 22:41:00
217
原创 826. Most Profit Assigning Work
We 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 of the ith worker, which means that this wo...
2019-01-09 21:59:21
307
原创 825. Friends Of Appropriate Ages
Some 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 (B != A) if any of the following conditions a...
2019-01-08 22:03:57
227
原创 830. Positions of Large Groups
In 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 “a”, “bb”, “xxxx”, “z” and “yy”.Call a grou...
2018-12-16 20:56:24
178
原创 822. Card Flipping Game
On 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 card.If the number X on the back ...
2018-12-16 20:27:41
232
原创 824. Goat Latin
A 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 Latin” (a made-up language simi...
2018-12-13 22:19:34
140
原创 821. Shortest Distance to a Character
Given 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: S = “loveleetcode”, C = ‘e’Output: [3, 2, 1, ...
2018-12-13 21:59:57
794
1
原创 820. Short Encoding of Words
Given 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 can write it as S = “time#bell#” and in...
2018-12-13 21:37:37
169
原创 819. Most Common Word
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...
2018-12-11 21:50:55
153
原创 817. Linked List Components
We 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 list.Return the number of connected components i...
2018-12-11 21:23:15
527
原创 816. Ambiguous Coordinates
We 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. Return a list of strings representing all...
2018-12-10 20:55:58
168
原创 815. Bus Routes
javaclass Solution { public int numBusesToDestination(int[][] routes, int S, int T) { if (S == T){ return 0; } List<List<Integer>&
2018-12-10 20:13:51
241
原创 814. Binary Tree Pruning
We are given the head node root of a binary tree, where additionally every node's value is either a 0 or a 1.Return the same tree where every subtree (of the given tree) not containing a 1 has been ...
2018-12-02 23:33:20
119
原创 813. Largest Sum of Averages
We 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 we can achieve?Note that our partition m...
2018-12-02 23:14:05
162
原创 812. Largest Triangle Area
You have a list of points in the plane. Return the area of the largest triangle that can be formed by any 3 of the points.Example:Input: points = [[0,0],[0,1],[1,0],[0,2],[2,0]]Output: 2Explanat...
2018-11-29 21:32:51
207
原创 798. Smallest Rotation with Highest Score
Given an array A, we may rotate it by a non-negative integer K so that the array becomes A[K], A[K+1], A{K+2], ... A[A.length - 1], A[0], A[1], ..., A[K-1]. Afterward, any entries that are less than...
2018-11-27 21:27:28
234
原创 799. Champagne Tower
We stack glasses in a pyramid, where the first row has 1 glass, the second row has 2 glasses, and so on until the 100th row. Each glass holds one cup (250ml) of champagne.Then, some champagne is po...
2018-11-27 20:30:35
309
1
原创 792. Number of Matching Subsequences
Given string S and a dictionary of words words, find the number of words[i] that is a subsequence of S.Example :Input: S = "abcde"words = ["a", "bb", "acd", "ace"]Output: 3Explanation: There a...
2018-11-26 22:19:29
175
原创 778. Swim in Rising Water
On an N x N grid, each square grid[i][j] represents the elevation at that point (i,j).Now rain starts to fall. At time t, the depth of the water everywhere is t. You can swim from a square to anothe...
2018-11-26 21:09:43
256
原创 779. K-th Symbol in Grammar
On the first row, we write a 0. Now in every subsequent row, we look at the previous row and replace each occurrence of 0 with 01, and each occurrence of 1 with 10.Given row N and index K, return th...
2018-11-25 21:04:57
209
原创 756. Pyramid Transition Matrix
We are stacking blocks to form a pyramid. Each block has a color which is a one letter string, like `'Z'`.For every block of color `C` we place not in the bottom row, we are placing it on top of a l...
2018-11-25 16:57:10
162
原创 811. Subdomain Visit Count
A website domain like "discuss.leetcode.com" consists of various subdomains. At the top level, we have "com", at the next level, we have "leetcode.com", and at the lowest level, "discuss.leetcode.com"...
2018-11-23 23:16:34
129
原创 807. Max Increase to Keep City Skyline
In a 2 dimensional array grid, each value grid[i][j] represents the height of a building located there. We are allowed to increase the height of any number of buildings, by any amount (the amounts can...
2018-11-23 23:03:15
123
原创 777. Swap Adjacent in LR String
In a string composed of 'L', 'R', and 'X' characters, like "RXXLRXRXL", a move consists of either replacing one occurrence of "XL" with "LX", or replacing one occurrence of "RX" with "XR". Given the s...
2018-11-21 22:10:17
197
原创 795. Number of Subarrays with Bounded Maximum
We are given an array A of positive integers, and two positive integers L and R (L <= R).Return the number of (contiguous, non-empty) subarrays such that the value of the maximum array element in...
2018-11-21 21:16:32
131
原创 781. Rabbits in Forest
In a forest, each rabbit has some color. Some subset of rabbits (possibly all of them) tell you how many other rabbits have the same color as them. Those answers are placed in an array.Return the mi...
2018-11-20 23:56:45
191
原创 773. Sliding Puzzle
On a 2x3 board, there are 5 tiles represented by the integers 1 through 5, and an empty square represented by 0.A move consists of choosing 0 and a 4-directionally adjacent number and swapping it....
2018-11-20 23:08:03
180
原创 802. Find Eventual Safe States
In a directed graph, we start at some node and every turn, walk along a directed edge of the graph. If we reach a node that is terminal (that is, it has no outgoing directed edges), we stop.Now, sa...
2018-11-20 00:34:57
132
原创 806. Number of Lines To Write String
We are to write the letters of a given string S, from left to right into lines. Each line has maximum width 100 units, and if writing a letter would cause the width of the line to exceed 100 units, it...
2018-11-19 23:35:36
103
原创 757. Set Intersection Size At Least Two
An integer interval [a, b] (for integers a < b) is a set of all consecutive integers from a to b, including aand b.Find the minimum size of a set S such that for every integer interval A in inter...
2018-11-19 23:15:54
160
原创 783. Minimum Distance Between BST Nodes
Given a Binary Search Tree (BST) with the root node root, return the minimum difference between the values of any two different nodes in the tree.Example :Input: root = [4,2,6,1,3,null,null]Outp...
2018-11-19 21:39:20
130
原创 768. Max Chunks To Make Sorted II
This question is the same as "Max Chunks to Make Sorted" except the integers of the given array are not necessarily distinct, the input array could be up to length 2000, and the elements could be up t...
2018-11-19 21:00:12
117
原创 769. Max Chunks To Make Sorted
Given an array arr that is a permutation of [0, 1, ..., arr.length - 1], we split the array into some number of "chunks" (partitions), and individually sort each chunk. After concatenating them, the ...
2018-11-18 21:31:33
98
原创 740. Delete and Earn
Given an array nums of integers, you can perform operations on the array.In each operation, you pick any nums[i] and delete it to earn nums[i] points. After, you must delete everyelement equal to nu...
2018-11-18 18:46:47
177
原创 767. Reorganize String
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.If possible, output any possible result. If not possible, return the...
2018-11-15 23:47:03
135
原创 804. Unique Morse Code Words
International Morse Code defines a standard encoding where each letter is mapped to a series of dots and dashes, as follows: "a" maps to ".-", "b" maps to "-...", "c" maps to "-.-.", and so on.F
2018-11-15 22:52:08
159
原创 797. All Paths From Source to Target
Given a directed, acyclic graph of N nodes. Find all possible paths from node 0 to node N-1, and return them in any order.The graph is given as follows: the nodes are 0, 1, ..., graph.length - 1. ...
2018-11-14 22:58:05
117
原创 796. Rotate String
We are given two strings, A and B.A shift on A consists of taking string A and moving the leftmost character to the rightmost position. For example, if A = 'abcde', then it will be 'bcdea' after one...
2018-11-14 22:49:01
177
原创 791. Custom Sort String
S and T are strings composed of lowercase letters. In S, no letter occurs more than once.S was sorted in some custom order previously. We want to permute the characters of T so that they match the o...
2018-11-14 22:40:49
135
原创 785. Is Graph Bipartite?
Given an undirected graph, return true if and only if it is bipartite.Recall that a graph is bipartite if we can split it's set of nodes into two independent subsets A and B such that every edge in ...
2018-11-14 22:06:13
148
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人