随笔分类 - RP
摘要:Given a binary search tree and a node in it, find the in-order successor of that node in the BST. 1 public class Solution { 2 3 public TreeNode inorde
        阅读全文
                
摘要:Range Sum Query 2D - Mutable Given a 2D matrix matrix, find the sum of the elements inside the rectangle defined by its upper left corner (row1, col1)
        阅读全文
                
摘要:Given two 1d vectors, implement an iterator to return their elements alternately. For example, given two 1d vectors: By calling next repeatedly until 
        阅读全文
                
摘要:Preorder: 因为是preorder traversal, 我们需要先print root,然后左节点,最后右节点,而且root左边子树一定比右边子树先print出来,所以,我们可以先把当前root的右节点压栈,然后把root的左节点压栈,这样每次从栈里取的时候,可以保证左边节点的root先取
        阅读全文
                
摘要:Validate if a given string is numeric. Some examples:"0" => true" 0.1 " => true"abc" => false"1 a" => false"2e10" => true Note: It is intended for the
        阅读全文
                
摘要:The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font 
        阅读全文
                
摘要:Factor Combinations Problem: 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 in
        阅读全文
                
摘要:A group of two or more people wants to meet and minimize the total travel distance. You are given a 2D grid of values 0 or 1, where each 1 marks the h
        阅读全文
                
摘要:Given two sparse matrices A and B, return the result of AB. You may assume that A's column number is equal to B's row number. Example: A = [ [ 1, 0, 0
        阅读全文
                
摘要:Remove Duplicate Letters I Given a string which contains only lowercase letters, remove duplicate letters so that every letter appear once and only on
        阅读全文
                
摘要:Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; } Populate each next pointer to point to its ne
        阅读全文
                
摘要:Given a set of distinct positive integers, find the largest subset such that every pair (Si, Sj) of elements in this subset satisfies: Si % Sj = 0 or 
        阅读全文
                
摘要: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
        阅读全文
                
摘要:Given a list of unique words. Find all pairs of distinct indices (i, j) in the given list, so that the concatenation of the two words, i.e.words[i] + 
        阅读全文
                
摘要:Flip Game I Problem Description: You are playing the following Flip Game with your friend: Given a string that contains only these two characters: + a
        阅读全文
                
摘要:Word Pattern | Given a pattern and a string str, find if str follows the same pattern. Examples: Notes: solution: Split the string, and add the pair t
        阅读全文
                
摘要:Given a list of words and two words word1 and word2, return the shortest distance between these two words in the list. For example, Assume that words 
        阅读全文
                
摘要:Convert a non-negative integer to its english words representation. Given input is guaranteed to be less than 231 - 1. For example, 123 -> "One Hundre
        阅读全文
                
摘要:Given an unsorted array, find the maximum difference between the successive elements in its sorted form. Return 0 if the array contains less than 2 el
        阅读全文
                
摘要:Given a non-empty array of integers, return the k most frequent elements. For example,Given [1,1,1,2,2,3] and k = 2, return [1,2]. 分析: http://blog.csd
        阅读全文
                
                    
                
浙公网安备 33010602011771号