摘要: Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [-2,1,-3,4,-1,2, 阅读全文
posted @ 2016-09-13 15:16 Machelsky 阅读(102) 评论(0) 推荐(0)
摘要: Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. F 阅读全文
posted @ 2016-09-13 13:41 Machelsky 阅读(122) 评论(0) 推荐(0)
摘要: A message containing letters from A-Z is being encoded to numbers using the following mapping: Given an encoded message containing digits, determine t 阅读全文
posted @ 2016-09-13 13:06 Machelsky 阅读(156) 评论(0) 推荐(0)
摘要: Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -. Example:Given a = 1 and b = 2, return 3. 思路:xor相加存无car 阅读全文
posted @ 2016-09-13 11:24 Machelsky 阅读(104) 评论(0) 推荐(0)
摘要: Given two strings s and t, write a function to determine if t is an anagram of s. For example,s = "anagram", t = "nagaram", return true.s = "rat", t = 阅读全文
posted @ 2016-09-13 10:43 Machelsky 阅读(124) 评论(0) 推荐(0)
摘要: Given a singly linked list, determine if it is a palindrome. 思路:stack存数,然后从头比较。 Solution2: Follow up: O(n) in time, O(1) in space. 思路:用reverse linkedl 阅读全文
posted @ 2016-09-13 08:54 Machelsky 阅读(109) 评论(0) 推荐(0)
摘要: Given a positive integer, return its corresponding column title as appear in an Excel sheet. For example: Solution2: 把数字减一再运算就不用考虑其他问题了。参考了discussion 阅读全文
posted @ 2016-09-13 07:08 Machelsky 阅读(156) 评论(0) 推荐(0)