随笔分类 - RP
摘要:Design a data structure that supports the following two operations: addWord(word) andsearch(word) search(word) can search a literal word or a regular 
        阅读全文
                
摘要:Given an unsorted array nums, reorder it in-place such that nums[0] <= nums[1] >= nums[2] <= nums[3].... Notice Please complete the problem in-place. 
        阅读全文
                
摘要:A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' -> 1 'B' -> 2 ... 'Z' -> 26 Given an encoded messag
        阅读全文
                
摘要:Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n. Example Given n = 12, retu
        阅读全文
                
摘要:House Robber You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constrain
        阅读全文
                
摘要:Given an integer array, heapify it into a min-heap array. For a heap array A, A[0] is the root of heap, and for each A[i], A[i * 2 + 1] is the left ch
        阅读全文
                
摘要:Coins in a Line I There are n coins in a line. Two players take turns to take one or two coins from right side until there are no more coins left. The
        阅读全文
                
摘要: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
        阅读全文
                
摘要:Given n, how many structurally unique BSTs (binary search trees) that store values 1...n? Given n, how many structurally unique BSTs (binary search tr
        阅读全文
                
摘要:Given a binary tree, find the maximum path sum. The path may start and end at any node in the tree. Example Given the below binary tree: 1 / \ 2 3 ret
        阅读全文
                
摘要:Given the root and two nodes in a Binary Tree. Find the lowest common ancestor(LCA) of the two nodes. The lowest common ancestor is the node with larg
        阅读全文
                
摘要:Given a sequence of integers, find the longest increasing subsequence (LIS). You code should return the length of the LIS. Clarification What's the de
        阅读全文
                
摘要: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
        阅读全文
                
摘要:Best Time to Buy and Sell Stock I Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted t
        阅读全文
                
摘要:Given a sorted array of n integers, find the starting and ending position of a given target value. If the target is not found in the array, return [-1
        阅读全文
                
摘要:There are two sorted arrays A and B of size m and nrespectively. Find the median of the two sorted arrays. There are two sorted arrays A and B of size
        阅读全文
                
摘要:Design an algorithm and write code to serialize and deserialize a binary tree. Writing the tree to a file is called 'serialization' and reading back f
        阅读全文
                
摘要:Jump Game | Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represent
        阅读全文
                
摘要:k Sum Given n distinct positive integers, integer k (k <= n) and a number target. Find k numbers where sum is target. Calculate how many solutions the
        阅读全文
                
摘要:Single Number Given 2*n + 1 numbers, every numbers occurs twice except one, find it. Example Given [1,2,2,1,3,4,3], return 4 分析: 利用bit operator ^ 的特点即
        阅读全文
                
                    
                
浙公网安备 33010602011771号