摘要: 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 (ie... 阅读全文
posted @ 2014-05-09 10:22 一弦一仙 阅读(142) 评论(0) 推荐(0) 编辑
摘要: java ReplaceAll 的两个参数都必须是正则表达式。在正则表达式中 \ (一个斜线)是用 \\ 来表示(即:用两个斜线表示一个斜线) 而在Java语言中 \ (一个斜线)是用 \\ 来表示。(即:也用两个斜线表示一个斜线) 所以正则表达式为两个斜线("\\")的写法,在Java语言中要用4... 阅读全文
posted @ 2014-05-09 09:23 一弦一仙 阅读(3789) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ ... 阅读全文
posted @ 2014-05-08 20:34 一弦一仙 阅读(158) 评论(0) 推荐(0) 编辑
摘要: http://oj.leetcode.com/problems/swap-nodes-in-pairs/Given a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4... 阅读全文
posted @ 2014-05-08 20:14 一弦一仙 阅读(147) 评论(0) 推荐(0) 编辑
摘要: http://oj.leetcode.com/problems/climbing-stairs/You are climbing a stair case. It takesnsteps to reach to the top.Each time you can either climb 1 or ... 阅读全文
posted @ 2014-05-08 20:08 一弦一仙 阅读(177) 评论(0) 推荐(0) 编辑
摘要: http://oj.leetcode.com/problems/maximum-subarray/Find the contiguous subarray within an array (containing at least one number) which has the largest s... 阅读全文
posted @ 2014-05-08 19:26 一弦一仙 阅读(183) 评论(0) 推荐(0) 编辑
摘要: Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in or... 阅读全文
posted @ 2014-05-07 23:15 一弦一仙 阅读(120) 评论(0) 推荐(0) 编辑
摘要: http://oj.leetcode.com/problems/balanced-binary-tree/http://blog.csdn.net/fightforyourdream/article/details/18693131Given a binary tree, determine if ... 阅读全文
posted @ 2014-05-07 22:55 一弦一仙 阅读(130) 评论(0) 推荐(0) 编辑
摘要: Given an array where elements are sorted in ascending order, convert it to a height balanced BST./** * Definition for binary tree * public class TreeN... 阅读全文
posted @ 2014-05-07 22:08 一弦一仙 阅读(154) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, return thebottom-up level ordertraversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For exa... 阅读全文
posted @ 2014-05-07 21:56 一弦一仙 阅读(146) 评论(0) 推荐(0) 编辑