12 2014 档案

Leetcode:Convert Sorted Array to Binary Search Tree
摘要:Given an array where elements are sorted in ascending order, convert it to a height balanced BST.分析:对于BST,左右子树的高度差小于等于1,则在由sorted array构建BST时把数组中间元素作为... 阅读全文

posted @ 2014-12-31 15:03 Ryan-Xing 阅读(115) 评论(0) 推荐(0)

Leetcode:Binary Tree Level Order Traversal II
摘要:Given a binary tree, return thebottom-up level ordertraversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For exa... 阅读全文

posted @ 2014-12-29 12:53 Ryan-Xing 阅读(154) 评论(0) 推荐(0)

Leetcode:Binary Tree Level Order Traversal
摘要:Given a binary tree, return thelevel ordertraversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree{3,9,2... 阅读全文

posted @ 2014-12-29 12:36 Ryan-Xing 阅读(128) 评论(0) 推荐(0)

Leetcode:Balanced Binary Tree
摘要:Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth... 阅读全文

posted @ 2014-12-29 12:24 Ryan-Xing 阅读(110) 评论(0) 推荐(0)

Binary Tree Maximum Path Sum
摘要:class Solution {public: int maxPathSum(TreeNode *root) { if(root == NULL) return 0; int max_sum = INT_MIN; unordered_map node_... 阅读全文

posted @ 2014-12-19 21:17 Ryan-Xing 阅读(113) 评论(0) 推荐(0)

Quant面试准备5本书
摘要:Heard on The Street: Quantitative Questions from Wall Street Job Interviews- Timothy Falcon CrackFrequently Asked Questions in Quantitative Finance- P... 阅读全文

posted @ 2014-12-19 21:15 Ryan-Xing 阅读(1853) 评论(0) 推荐(1)

Leetcode: Evaluate Reverse Polish Notation
摘要:Evaluate the value of an arithmetic expression inReverse Polish Notation.Valid operators are+,-,*,/. Each operand may be an integer or another express... 阅读全文

posted @ 2014-12-15 21:30 Ryan-Xing 阅读(126) 评论(0) 推荐(0)

Leetcode: Largest Rectangle in Histogram
摘要:Givennnon-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histog... 阅读全文

posted @ 2014-12-12 20:34 Ryan-Xing 阅读(136) 评论(0) 推荐(0)

Leetcode: Valid Number
摘要:Validate if a given string is numeric.Some examples:"0"=>true" 0.1 "=>true"abc"=>false"1 a"=>false"2e10"=>trueNote:It is intended for the problem stat... 阅读全文

posted @ 2014-12-12 12:54 Ryan-Xing 阅读(240) 评论(0) 推荐(0)

Leetcode: Anagrams
摘要:Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.分析:此题的题意不是很明确,意思重新表述应该是一组string里面,有几个... 阅读全文

posted @ 2014-12-10 20:56 Ryan-Xing 阅读(155) 评论(0) 推荐(0)

Leetcode: Distinct Subsequences
摘要:Given a stringSand a stringT, count the number of distinct subsequences ofTinS.A subsequence of a string is a new string which is formed from the orig... 阅读全文

posted @ 2014-12-10 14:01 Ryan-Xing 阅读(129) 评论(0) 推荐(0)

Python下载Yahoo!Finance数据
摘要:Python下载Yahoo!Finance数据的三种工具:(1)yahoo-finance package.(2)ystockquote.(3)pandas. 阅读全文

posted @ 2014-12-09 22:01 Ryan-Xing 阅读(1779) 评论(0) 推荐(0)

Leetcode: Integer to Roman
摘要:Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.分析:这道题参考leetcode.pdf的解法,代码简洁,处理的巧妙。值得借鉴的几点如下... 阅读全文

posted @ 2014-12-09 20:26 Ryan-Xing 阅读(92) 评论(0) 推荐(0)

Leetcode: Interleaving String
摘要:Givens1,s2,s3, find whethers3is formed by the interleaving ofs1ands2.For example,Given:s1="aabcc",s2="dbbca",Whens3="aadbbcbcac", return true.Whens3="... 阅读全文

posted @ 2014-12-09 19:46 Ryan-Xing 阅读(131) 评论(0) 推荐(0)

Leetcode: Length of Last Word
摘要:Given a stringsconsists of upper/lower-case alphabets and empty space characters' ', return the length of last word in the string.If the last word doe... 阅读全文

posted @ 2014-12-09 13:35 Ryan-Xing 阅读(89) 评论(0) 推荐(0)

Leetcode: Longest Common Prefix
摘要:Write a function to find the longest common prefix string amongst an array of strings.分析:这道题没什么好方法,暴力搜索比较即可,在用C++实现时有一个小trick就是"Ifposis equal to thest... 阅读全文

posted @ 2014-12-09 12:47 Ryan-Xing 阅读(91) 评论(0) 推荐(0)

Leetcode: Longest Palindromic Substring
摘要:Given a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there exists one unique longest pa... 阅读全文

posted @ 2014-12-09 12:07 Ryan-Xing 阅读(184) 评论(0) 推荐(0)

Leetcode: Longest Substring Without Repeating Characters
摘要:Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters fo... 阅读全文

posted @ 2014-12-08 19:39 Ryan-Xing 阅读(132) 评论(0) 推荐(0)

Leetcode: Binary Tree Maximum Path Sum
摘要:Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the below binary tree, 1 ... 阅读全文

posted @ 2014-12-08 12:46 Ryan-Xing 阅读(176) 评论(0) 推荐(0)

Leetcode: Edit Distance
摘要:Given two wordsword1andword2, find the minimum number of steps required to convertword1toword2. (each operation is counted as 1 step.)You have the fol... 阅读全文

posted @ 2014-12-07 16:18 Ryan-Xing 阅读(131) 评论(0) 推荐(0)

Leetcode: Sort Colors
摘要:Given an array withnobjects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, wh... 阅读全文

posted @ 2014-12-07 15:36 Ryan-Xing 阅读(165) 评论(0) 推荐(0)

Leetcode: Word Search
摘要:Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where "adjace... 阅读全文

posted @ 2014-12-07 00:47 Ryan-Xing 阅读(116) 评论(0) 推荐(0)

Leetcode: Intersection of Two Linked Lists
摘要:Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: a... 阅读全文

posted @ 2014-12-06 20:22 Ryan-Xing 阅读(146) 评论(0) 推荐(0)

Leetcode: Generate Parentheses
摘要:Givennpairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, givenn= 3, a solution set is:"((()))... 阅读全文

posted @ 2014-12-05 21:16 Ryan-Xing 阅读(186) 评论(0) 推荐(0)

Leetcode: Maximum Depth of Binary Tree
摘要:Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest le... 阅读全文

posted @ 2014-12-05 19:55 Ryan-Xing 阅读(114) 评论(0) 推荐(0)

Leetcode: Pascal's Triangle II
摘要:Given an indexk, return thekthrow of the Pascal's triangle.For example, givenk= 3,Return[1,3,3,1].Note:Could you optimize your algorithm to use onlyO(... 阅读全文

posted @ 2014-12-05 17:07 Ryan-Xing 阅读(145) 评论(0) 推荐(0)

Leetcode: strStr()
摘要:Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.分析:该题是经典的串匹配,我们可以用KMP来解,时间... 阅读全文

posted @ 2014-12-05 15:40 Ryan-Xing 阅读(213) 评论(0) 推荐(0)

Leetcode: Binary Tree Postorder Traversal
摘要:Given a binary tree, return thepostordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[3,2,1].No... 阅读全文

posted @ 2014-12-04 20:51 Ryan-Xing 阅读(131) 评论(0) 推荐(0)

Leetcode: Binary Tree Preorder Traversal
摘要:Given a binary tree, return thepreordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,2,3].Not... 阅读全文

posted @ 2014-12-04 20:20 Ryan-Xing 阅读(200) 评论(0) 推荐(0)

Leetcode: Binary Tree Inorder Traversal
摘要:Given a binary tree, return theinordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,3,2].Note... 阅读全文

posted @ 2014-12-04 20:07 Ryan-Xing 阅读(214) 评论(0) 推荐(0)

Leetcode: Longest Valid Parentheses
摘要:Given a string containing just the characters'('and')', find the length of the longest valid (well-formed) parentheses substring.For"(()", the longest... 阅读全文

posted @ 2014-12-04 19:15 Ryan-Xing 阅读(175) 评论(0) 推荐(0)

Leetcode: Multiply Strings
摘要:Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and are non-nega... 阅读全文

posted @ 2014-12-04 15:01 Ryan-Xing 阅读(126) 评论(0) 推荐(0)

Leetcode: Climbing Stairs
摘要:You are climbing a stair case. It takesnsteps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb... 阅读全文

posted @ 2014-12-03 23:59 Ryan-Xing 阅读(111) 评论(0) 推荐(0)

Leetcode: Regular Expression Matching
摘要:Implement regular expression matching with support for'.'and'*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.The... 阅读全文

posted @ 2014-12-03 22:14 Ryan-Xing 阅读(157) 评论(0) 推荐(0)

Leetcode: Restore IP Addresses
摘要:Given a string containing only digits, restore it by returning all possible valid IP address combinations.For example:Given"25525511135",return["255.2... 阅读全文

posted @ 2014-12-02 21:45 Ryan-Xing 阅读(124) 评论(0) 推荐(0)

Leetcode: Roman to Integer
摘要:Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.分析:首先我们熟悉下Roman数字组成规则:罗马数字一共有7个符号,'I':1, 'V'... 阅读全文

posted @ 2014-12-02 20:40 Ryan-Xing 阅读(141) 评论(0) 推荐(0)

Leetcode: Scramble String
摘要:Given a strings1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representation... 阅读全文

posted @ 2014-12-02 19:39 Ryan-Xing 阅读(176) 评论(0) 推荐(0)

Leetcode: Simplify Path
摘要:Given an absolute path for a file (Unix-style), simplify it.For example,path="/home/", =>"/home"path="/a/./b/../../c/", =>"/c"click to show corner cas... 阅读全文

posted @ 2014-12-02 17:20 Ryan-Xing 阅读(162) 评论(0) 推荐(0)

Leetcode: String to Integer (atoi)
摘要:Implementatoito convert a string to an integer.Hint:Carefully consider all possible input cases. If you want a challenge, please do not see below and ... 阅读全文

posted @ 2014-12-02 15:29 Ryan-Xing 阅读(273) 评论(0) 推荐(0)