摘要: 解题思路:中序遍历,左子树-根节点-右子树JAVA实现如下: public List inorderTraversal(TreeNode root) { List list = new ArrayList(); if(root==null) r... 阅读全文
posted @ 2015-05-20 22:55 TonyLuis 阅读(169) 评论(0) 推荐(0) 编辑
摘要: Given a string containing only digits, restore it by returning all possible valid IP address combinations. For example:Given "25525511135",return ["25... 阅读全文
posted @ 2015-05-20 22:16 TonyLuis 阅读(165) 评论(0) 推荐(0) 编辑
摘要: Reverse a linked list from position m to n. Do it in-place and in one-pass. For example:Given 1->2->3->4->5->NULL, m = 2 and n = 4,return 1->4->3->2->... 阅读全文
posted @ 2015-05-20 10:57 TonyLuis 阅读(137) 评论(0) 推荐(0) 编辑
摘要: A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message con... 阅读全文
posted @ 2015-05-20 10:18 TonyLuis 阅读(184) 评论(0) 推荐(0) 编辑
摘要: Given a collection of integers that might contain duplicates, nums, return all possible subsets.Note:Elements in a subset must be in non-descending or... 阅读全文
posted @ 2015-05-20 01:01 TonyLuis 阅读(157) 评论(0) 推荐(0) 编辑
摘要: The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the total numb... 阅读全文
posted @ 2015-05-20 00:52 TonyLuis 阅读(167) 评论(0) 推荐(0) 编辑
摘要: Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.解题思路一:使用一个nums1Copy把nums1的前m个元素拷贝出来,然后把nums1Copy和nums2放进nu... 阅读全文
posted @ 2015-05-20 00:20 TonyLuis 阅读(118) 评论(0) 推荐(0) 编辑