上一页 1 2 3 4 5 6 7 8 9 10 ··· 15 下一页

2018年11月6日

85. Maximal Rectangle

摘要: Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area. Example: Input: [ ["1","0","1","0","0"], ["1","0","1","1","1"], [" 阅读全文

posted @ 2018-11-06 11:52 猪猪🐷 阅读(101) 评论(0) 推荐(0)

642. Design Search Autocomplete System

摘要: 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 retu... 阅读全文

posted @ 2018-11-06 10:12 猪猪🐷 阅读(207) 评论(0) 推荐(0)

648. Replace Words

摘要: In English, we have a concept called root, which can be followed by some other words to form another longer word - let's call this word successor. For example, the root an, followed by other, which c... 阅读全文

posted @ 2018-11-06 10:11 猪猪🐷 阅读(176) 评论(0) 推荐(0)

745. Prefix and Suffix Search

摘要: Given many words, words[i] has weight i. 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 ma... 阅读全文

posted @ 2018-11-06 10:10 猪猪🐷 阅读(164) 评论(0) 推荐(0)

676. Implement Magic Dictionary

摘要: Implement a magic directory with buildDict, and search methods. For the method buildDict, you'll be given a list of non-repetitive words to build a dictionary. For the method search, you'll be given ... 阅读全文

posted @ 2018-11-06 10:09 猪猪🐷 阅读(132) 评论(0) 推荐(0)

720. Longest Word in Dictionary

摘要: Given a list of strings words representing an English Dictionary, find the longest word in words that can be built one character at a time by other words in words. If there is more than one possible ... 阅读全文

posted @ 2018-11-06 10:08 猪猪🐷 阅读(187) 评论(0) 推荐(0)

225. Implement Stack using Queues

摘要: Implement the following operations of a stack using queues. push(x) -- Push element x onto stack. pop() -- Removes the element on top of the stack. to 阅读全文

posted @ 2018-11-06 10:01 猪猪🐷 阅读(114) 评论(0) 推荐(0)

232. Implement Queue using Stacks

摘要: https://www.youtube.com/watch?v=ma1S6vtkw9I https://www.youtube.com/watch?v=jf0NTM_JS0w Implement the following operations of a queue using stacks. * push(x) -- Push element x to the back of queu... 阅读全文

posted @ 2018-11-06 10:01 猪猪🐷 阅读(75) 评论(0) 推荐(0)

716. Max Stack

摘要: Design a max stack that supports push, pop, top, peekMax and popMax. 1. push(x) -- Push element x onto stack. 2. pop() -- Remove the element on top of the stack and return it. 3. top() -- Get the el... 阅读全文

posted @ 2018-11-06 10:00 猪猪🐷 阅读(144) 评论(0) 推荐(0)

460 LFU Cache / O(1)

摘要: Design and implement a data structure for Least Frequently Used (LFU) cache. It should support the following operations: get and put. get(key) - Get the value (will always be positive) of the key if ... 阅读全文

posted @ 2018-11-06 09:59 猪猪🐷 阅读(150) 评论(0) 推荐(0)

432. All O`one Data Structure

摘要: Implement a data structure supporting the following operations: 1. Inc(Key) - Inserts a new key with value 1. Or increments an existing key by 1. Key is guaranteed to be a non-empty string. 2. Dec(K... 阅读全文

posted @ 2018-11-06 09:58 猪猪🐷 阅读(102) 评论(0) 推荐(0)

359. Logger Rate Limiter

摘要: Design a logger system that receive stream of messages along with its timestamps, each message should be printed if and only if it is not printed in the last 10 seconds. Given a message and a timesta... 阅读全文

posted @ 2018-11-06 09:58 猪猪🐷 阅读(121) 评论(0) 推荐(0)

245. Shortest Word Distance III

摘要: Given a list of words and two words word1 and word2, return the shortest distance between these two words in the list. word1 and word2 may be the same and they represent two individual words in the l... 阅读全文

posted @ 2018-11-06 09:45 猪猪🐷 阅读(157) 评论(0) 推荐(0)

465. Optimal Account Balancing

摘要: A group of friends went on holiday and sometimes lent each other money. For example, Alice paid for Bill's lunch for $10. Then later Chris gave Alice $5 for a taxi ride. We can model each transactio... 阅读全文

posted @ 2018-11-06 09:43 猪猪🐷 阅读(133) 评论(0) 推荐(0)

694. Number of Distinct Islands

摘要: Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of the grid are surro... 阅读全文

posted @ 2018-11-06 09:42 猪猪🐷 阅读(89) 评论(0) 推荐(0)

802. Find Eventual Safe States

摘要: Approach #2: Depth-First Search [Accepted] Intuition As in Approach #1, the crux of the problem is whether you reach a cycle or not. Let us perform a 阅读全文

posted @ 2018-11-06 09:41 猪猪🐷 阅读(163) 评论(0) 推荐(0)

261. Graph Valid Tree

摘要: Given n nodes labeled from 0 to n-1 and a list of undirected edges (each edge is a pair of nodes), write a function to check whether these edges make up a valid tree. Example 1: Input: n = 5, and edg... 阅读全文

posted @ 2018-11-06 09:41 猪猪🐷 阅读(84) 评论(0) 推荐(0)

547. Friend Circles

摘要: There are N students in a class. Some of them are friends, while some are not. Their friendship is transitive in nature. For example, if A is a direct friend of B, and B is a direct friend of C, then... 阅读全文

posted @ 2018-11-06 09:37 猪猪🐷 阅读(122) 评论(0) 推荐(0)

200. Number of Islands

摘要: Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assum... 阅读全文

posted @ 2018-11-06 09:36 猪猪🐷 阅读(107) 评论(0) 推荐(0)

37 Sudoku Solver

摘要: two things: 带返回值的dfs recursion if(board[3 * (row / 3) + i / 3][ 3 * (col / 3) + i % 3] != '.' && board[3 * (row / 3) + i / 3][3 * (col / 3) + i % 3] = 阅读全文

posted @ 2018-11-06 09:34 猪猪🐷 阅读(91) 评论(0) 推荐(0)

698. Partition to K Equal Sum Subsets

摘要: 带返回值的dfs recursion 阅读全文

posted @ 2018-11-06 09:34 猪猪🐷 阅读(120) 评论(0) 推荐(0)

679. 24 Game

摘要: https://leetcode.com/problems/24-game/solution/ You have 4 cards each containing a number from 1 to 9. You need to judge whether they could operated through *, /, +, -, (, ) to get the value of 24. E... 阅读全文

posted @ 2018-11-06 09:33 猪猪🐷 阅读(136) 评论(0) 推荐(0)

241. Different Ways to Add Parentheses

摘要: Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. The valid operators are +, - and *. Example 1: Inpu... 阅读全文

posted @ 2018-11-06 09:30 猪猪🐷 阅读(106) 评论(0) 推荐(0)

425. Word Squares

摘要: Given a set of words (without duplicates), find all word squares you can build from them. A sequence of words forms a valid word square if the kth row and column read the exact same string, where 0 ≤... 阅读全文

posted @ 2018-11-06 09:29 猪猪🐷 阅读(119) 评论(0) 推荐(0)

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. ... 阅读全文

posted @ 2018-11-06 09:28 猪猪🐷 阅读(165) 评论(0) 推荐(0)

254. Factor Combinations

摘要: Numbers can be regarded as product of its factors. For example, 8 = 2 x 2 x 2; = 2 x 4. Write a function that takes an integer n and return all possible combinations of its factors. Note: 1. You ma... 阅读全文

posted @ 2018-11-06 09:27 猪猪🐷 阅读(101) 评论(0) 推荐(0)

291. Word Pattern II

摘要: The method startsWith() is used for checking prefix of a String. It returns a boolean value true or false based on whether the specified string is pre 阅读全文

posted @ 2018-11-06 09:25 猪猪🐷 阅读(108) 评论(0) 推荐(0)

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. For c... 阅读全文

posted @ 2018-11-06 09:24 猪猪🐷 阅读(111) 评论(0) 推荐(0)

51 N-Queens

摘要: The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.  Given an integer n, return all distinct solutions to the n-queens puzzle. Each... 阅读全文

posted @ 2018-11-06 09:23 猪猪🐷 阅读(156) 评论(0) 推荐(0)

310. Minimum Height Trees

摘要: https://leetcode.com/problems/minimum-height-trees/discuss/76055/Share-some-thoughts For a undirected graph with tree characteristics, we can choose any node as the root. The result graph is then a... 阅读全文

posted @ 2018-11-06 09:09 猪猪🐷 阅读(122) 评论(0) 推荐(0)

542. 01 Matrix

摘要: Given a matrix consists of 0 and 1, find the distance of the nearest 0 for each cell. The distance between two adjacent cells is 1. Example 1: Input: 0 0 0 0 1 0 0 0 0 Output: 0 0 0 0 1 0 0 0 0 Exa... 阅读全文

posted @ 2018-11-06 09:08 猪猪🐷 阅读(90) 评论(0) 推荐(0)

787. Cheapest Flights Within K Stops

摘要: There are n cities connected by m flights. Each fight starts from city u and arrives at v with a price w. Now given all the cities and flights, togeth 阅读全文

posted @ 2018-11-06 08:50 猪猪🐷 阅读(167) 评论(0) 推荐(0)

407. Trapping Rain Water II

摘要: Example: The above image represents the elevation map [[1,4,3,1,3,2],[3,2,1,3,2,4],[2,3,3,2,3,1]] before the rain. After the rain, water is trapped be 阅读全文

posted @ 2018-11-06 08:49 猪猪🐷 阅读(123) 评论(0) 推荐(0)

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... 阅读全文

posted @ 2018-11-06 08:45 猪猪🐷 阅读(81) 评论(0) 推荐(0)

490. The Maze

摘要: There is a ball in a maze with empty spaces and walls. The ball can go through empty spaces by rolling up, down, left or right, but it won't stop roll 阅读全文

posted @ 2018-11-06 08:44 猪猪🐷 阅读(126) 评论(0) 推荐(0)

505. The Maze II

摘要: There is a ball in a maze with empty spaces and walls. The ball can go through empty spaces by rolling up, down, left or right, but it won't stop roll 阅读全文

posted @ 2018-11-06 08:43 猪猪🐷 阅读(100) 评论(0) 推荐(0)

373. Find K Pairs with Smallest Sums

摘要: You are given two integer arrays nums1 and nums2 sorted in ascending order and an integer k. Define a pair (u,v) which consists of one element from the first array and one element from the second arr... 阅读全文

posted @ 2018-11-06 08:42 猪猪🐷 阅读(90) 评论(0) 推荐(0)

499. The Maze III

摘要: There is a ball in a maze with empty spaces and walls. The ball can go through empty spaces by rolling up (u), down (d), left (l) or right (r), but it won't stop rolling until hitting a wall. When th... 阅读全文

posted @ 2018-11-06 08:42 猪猪🐷 阅读(143) 评论(0) 推荐(0)

264. Ugly Number II

摘要: Write a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. Example: Input: n = 10 Output: 12 Explanation: 1, 2, 3, 4, 5, 6, 8, 9, 10, 1... 阅读全文

posted @ 2018-11-06 08:41 猪猪🐷 阅读(73) 评论(0) 推荐(0)

668. Kth Smallest Number in Multiplication Table

摘要: Nearly every one have used the Multiplication Table. But could you find out the k-th smallest number quickly from the multiplication table? Given the height m and the length n of a m * n Multiplicati... 阅读全文

posted @ 2018-11-06 08:40 猪猪🐷 阅读(79) 评论(0) 推荐(0)

上一页 1 2 3 4 5 6 7 8 9 10 ··· 15 下一页

导航