摘要:LRU CacheDesign and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations:getandset.get(key)- Get...
阅读全文
摘要:Maximal RectangleGiven a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.Show TagsHave yo...
阅读全文
摘要:Min Stack My SubmissionsQuestionSolutionDesign a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Pu...
阅读全文
摘要:Restore IP AddressesMy SubmissionsQuestionSolutionGiven a string containing only digits, restore it by returning all possible valid IP address combina...
阅读全文
摘要:Longest Common Prefix Total Accepted: 24665 Total Submissions: 92370My SubmissionsQuestionSolutionWrite a function to find the longest common prefix s...
阅读全文
摘要:Regular Expression Matching My Submissions Question Solution Implement regular expression matching with support for '.' and '*'. '.' Matches any singl
阅读全文
摘要:Sudoku SolverWrite a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character '.'.You may assume that th...
阅读全文
摘要:Valid SudokuDetermine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are...
阅读全文
摘要:AnagramsGiven an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.思路:建Hashtable,用排序过的string作为ke...
阅读全文
摘要:Valid NumberValidate if a given string is numeric.Some examples:"0" => true" 0.1 " => true"abc" => false"1 a" => false"2e10" => trueNote: It is intend...
阅读全文
摘要:https://oj.leetcode.com/problems/trapping-rain-water/Trapping Rain WaterGiven n non-negative integers representing an elevation map where the width of...
阅读全文
摘要:Container With Most WaterGiven n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are draw...
阅读全文
摘要:Add BinaryGiven two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".SOLUTION:指针指到两个字符串的末尾,不断往前推进,用carr...
阅读全文
摘要:Merge IntervalsGiven a collection of intervals, merge all overlapping intervals.For example,Given [1,3],[2,6],[8,10],[15,18],return [1,6],[8,10],[15,1...
阅读全文
摘要:Longest Consecutive SequenceGiven an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given [100, ...
阅读全文
摘要:Rotate ImageYou are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?SOL...
阅读全文
摘要:Divide Two IntegersDivide two integers without using multiplication, division and mod operator.SOLUTION 11. 基本思想是不断地减掉除数,直到为0为止。但是这样会太慢。2. 我们可以使用2分法来加...
阅读全文
摘要:Find Minimum in Rotated Sorted Array II Follow up for "Find Minimum in Rotated Sorted Array":What if duplicates are allowed?Would this affect the run-...
阅读全文
摘要:Find Minimum in Rotated Sorted ArrayQuestion SolutionSuppose a sorted array is rotated at some pivot unknown to youbeforehand.(i.e., 0 1 2 4 5 6 7 mig...
阅读全文
摘要:CandyThere are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the followin...
阅读全文