摘要: 题目:Given amxngrid filled with non-negative numbers, find a path from top left to bottom right whichminimizesthe sum of all numbers along its path.Note... 阅读全文
posted @ 2015-10-14 17:45 savageclc26 阅读(102) 评论(0) 推荐(0) 编辑
摘要: 题目:You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 s... 阅读全文
posted @ 2015-10-13 22:10 savageclc26 阅读(120) 评论(0) 推荐(0) 编辑
摘要: 题目:Givennpairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, givenn= 3, a solution set is:"(((... 阅读全文
posted @ 2015-10-12 22:17 savageclc26 阅读(146) 评论(0) 推荐(0) 编辑
摘要: 题目:Say you have an array for which theithelement is the price of a given stock on dayi.If you were only permitted to complete at most one transaction ... 阅读全文
posted @ 2015-10-12 12:07 savageclc26 阅读(104) 评论(0) 推荐(0) 编辑
摘要: 题目:A robot is located at the top-left corner of amxngrid (marked 'Start' in the diagram below).The robot can only move either down or right at any poi... 阅读全文
posted @ 2015-10-12 11:28 savageclc26 阅读(110) 评论(0) 推荐(0) 编辑
摘要: 题目:Given a binary tree, return thepostordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[3,2,1]... 阅读全文
posted @ 2015-10-09 17:38 savageclc26 阅读(139) 评论(0) 推荐(0) 编辑
摘要: 题目:Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e.,0 1 2 4 5 6 7might become4 5 6 7 0 1 2).Find the minimum element.Yo... 阅读全文
posted @ 2015-10-09 12:10 savageclc26 阅读(101) 评论(0) 推荐(0) 编辑
摘要: 题目:Reverse a singly linked list.思路1:直接用循环遍历即可代码: public static ListNode reverseList(ListNode head) { if(head == null || head.next == null){ ... 阅读全文
posted @ 2015-10-09 10:23 savageclc26 阅读(89) 评论(0) 推荐(0) 编辑
摘要: 题目:Given an array where elements are sorted in ascending order, convert it to a height balanced BST.分析:平衡二叉树的特点:左右子树的高度差不能超过1采用二分查找思想和递归思想代码: publi... 阅读全文
posted @ 2015-10-09 09:21 savageclc26 阅读(111) 评论(0) 推荐(0) 编辑
摘要: 题目: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 @ 2015-10-08 12:10 savageclc26 阅读(103) 评论(0) 推荐(0) 编辑