摘要: Find the sum of all left leaves in a given binary tree. Example: 更简洁的写法: 迭代解法: 另外也可以在迭代过程中绕过叶子结点: 阅读全文
posted @ 2018-03-27 23:23 bonelee 阅读(216) 评论(0) 推荐(0)
摘要: Given two binary trees, write a function to check if they are the same or not. Two binary trees are considered the same if they are structurally ident 阅读全文
posted @ 2018-03-27 22:55 bonelee 阅读(232) 评论(0) 推荐(0)
摘要: Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the rans 阅读全文
posted @ 2018-03-27 22:36 bonelee 阅读(188) 评论(0) 推荐(0)
摘要: Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may comple 阅读全文
posted @ 2018-03-27 22:18 bonelee 阅读(204) 评论(0) 推荐(0)
摘要: Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. Roman Numerals Chart M=1000 D = 500 I 1 XX 阅读全文
posted @ 2018-03-27 21:23 bonelee 阅读(371) 评论(0) 推荐(0)
摘要: import re pattern = re.compile( r'^(([a-zA-Z]{1})|([a-zA-Z]{1}[a-zA-Z]{1})|' r'([a-zA-Z]{1}[0-9]{1})|([0-9]{1}[a-zA-Z]{1})|' r'([a-zA-Z0-9][-_.a-zA-Z0-9]{0,61}[a-zA-Z0-9]))\.' r'([a... 阅读全文
posted @ 2018-03-27 12:01 bonelee 阅读(4831) 评论(0) 推荐(0)