随笔分类 - Uber
摘要:Given a string that contains only digits 0-9 and a target value, return all possibilities to add binary operators (not unary) +, -, or *between the di
阅读全文
摘要:Remove the minimum number of invalid parentheses in order to make the input string valid. Return all possible results. Note: The input string may cont
阅读全文
摘要:You are given a m x n 2D grid initialized with these three possible values. -1 - A wall or an obstacle. 0 - A gate. INF - Infinity means an empty room
阅读全文
摘要:According to the Wikipedia's article: "The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John
阅读全文
摘要:The API: int read4(char *buf) reads 4 characters at a time from a file. The return value is the actual number of characters read. For example, it retu
阅读全文
摘要:Given an array of words and a length L, format the text such that each line has exactly L characters and is fully (left and right) justified. You shou
阅读全文
摘要:Nested List Weight Sum I Given a nested list of integers, return the sum of all integers in the list weighted by their depth. Each element is either a
阅读全文
摘要:Design an algorithm to encode a list of strings to a string. The encoded string is then sent over the network and is decoded back to the original list
阅读全文
摘要:Given a nested list of integers, implement an iterator to flatten it. Each element is either an integer, or a list -- whose elements may also be integ
阅读全文
摘要:Word Ladder I Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that: Onl
阅读全文
摘要:Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and put. get(key) - Get the
阅读全文
摘要:Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.
阅读全文
摘要:Insert Intervals Given a non-overlapping interval list which is sorted by start point. Insert a new interval into it, make sure the list is still in o
阅读全文
摘要:Determine whether a Sudoku is valid. The Sudoku board could be partially filled, where empty cells are filled with the character .. Notice A valid Sud
阅读全文
摘要:Given a boolean 2D matrix, find the number of islands. Notice 0 is represented as the sea, 1 is represented as the island. If two 1 is adjacent, we co
阅读全文
摘要:Given an unsorted integer array, find the first missing positive integer. Example Given [1,2,0] return 3,and [3,4,-1,1] return 2. 分析: 我们只需要把1到A.length
阅读全文
摘要:Design an iterator over a binary search tree with the following rules: Elements are visited in ascending order (i.e. an in-order traversal) next() and
阅读全文
摘要:For an array A, if i < j, and A [i] > A [j], called (A [i], A [j]) is a reverse pair.return total of reverse pairs in A. For an array A, if i < j, and
阅读全文
摘要:Two Sum I Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of
阅读全文
摘要:Given an integers array A. Define B[i] = A[0] * ... * A[i-1] * A[i+1] * ... * A[n-1], calculate B WITHOUT divide operation. Example For A = [1, 2, 3],
阅读全文