2018年11月6日

726. Number of Atoms

摘要: Given a chemical formula (given as a string), return the count of each atom. An atomic element always starts with an uppercase character, then zero or more lowercase letters, representing the name. 1... 阅读全文

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

294. Flip Game II

摘要: You are playing the following Flip Game with your friend: Given a string that contains only these two characters: + and -, you and your friend take turns to flip two consecutive "++" into "--". The g... 阅读全文

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

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)

导航