Fork me on GitHub
摘要: Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree [1,2,2,3,4,4,3] is symmet 阅读全文
posted @ 2017-03-28 23:13 hellowOOOrld 阅读(223) 评论(0) 推荐(0)
摘要: Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. 思路: 由于链表 阅读全文
posted @ 2017-03-27 22:55 hellowOOOrld 阅读(214) 评论(0) 推荐(0)
摘要: Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. 思路:利用快慢指针找到中间节点,作为根节点,然后左子树即为左边链表部分,右子树即 阅读全文
posted @ 2017-03-26 23:27 hellowOOOrld 阅读(858) 评论(0) 推荐(0)
摘要: We define the Perfect Number is a positive integer that is equal to the sum of all its positive divisors except itself. Now, given an integer n, write 阅读全文
posted @ 2017-03-26 11:16 hellowOOOrld 阅读(331) 评论(0) 推荐(0)
摘要: Given two strings representing two complex numbers. You need to return a string representing their multiplication. Note i2 = -1 according to the defin 阅读全文
posted @ 2017-03-26 11:13 hellowOOOrld 阅读(489) 评论(0) 推荐(0)
摘要: Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 思路: 由于是有序数组,那么根节点肯定是中间的那个数字,然后递归处理左子树和右子树即可。 阅读全文
posted @ 2017-03-23 16:53 hellowOOOrld 阅读(170) 评论(0) 推荐(0)
摘要: Given a binary tree, find the maximum path sum. For this problem, a path is defined as any sequence of nodes from some starting node to any node in th 阅读全文
posted @ 2017-03-23 15:18 hellowOOOrld 阅读(164) 评论(0) 推荐(0)
摘要: Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", the answer is "abc", which the leng 阅读全文
posted @ 2017-03-16 16:53 hellowOOOrld 阅读(156) 评论(0) 推荐(0)
摘要: Implement pow(x, n). 开始的时候思路很朴素,隐约觉得不太对劲。。果然,超时了。 然后,再仔细琢磨,发现可以缩短时间,缩短到 O(lgn)的复杂度。 比如8个2相乘的话,可以表示为4的平方,4又可以表示为2的平方,只需三次即可算出。 参考: https://discuss.leet 阅读全文
posted @ 2017-03-15 17:06 hellowOOOrld 阅读(172) 评论(0) 推荐(0)
摘要: 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 阅读全文
posted @ 2017-03-15 15:43 hellowOOOrld 阅读(174) 评论(0) 推荐(0)