2014年4月15日

【LeetCode练习题】Pow(x, n)

摘要: Pow(x, n)Implement pow(x,n).计算x的n次方。解题思路:考虑到n的值会很大,而且可为正可为负可为0,所以掉渣天的方法就是用递归了。对了,这题也在《剑指offer》里面有提到,是面试题11:数值的整数次方。可以书里给的递归代码在n为负数的情况下是错误的……他没有考虑到n为奇数... 阅读全文

posted @ 2014-04-15 19:16 Allen Blue 阅读(203) 评论(0) 推荐(0) 编辑

【Python脚本】Python创建删除文件-----------我的第一个Python脚本

摘要: Python相对C++和Java来说,是解释性语言,非常适合来编写脚本。很久之前就开始学习Python的语法了,今天写了第一个Python的脚本,来简化我的一些日常工作。我平时学习的时候喜欢新建一个word文档来记笔记,并以当天的日期来命名。就像是酱紫:于是我每天都得苦逼的先看看今天是几月几号,然后... 阅读全文

posted @ 2014-04-15 18:19 Allen Blue 阅读(6014) 评论(7) 推荐(2) 编辑

递归反转栈的顺序-------只使用常数量个变量

摘要: 昨天去阿里巴巴参加Java研发工程师的实习生面试,遇到的一个题目:我们要反转一个栈,如果使用另外一个栈作为辅助的话,那么反转起来很简单,一个接一个push到辅助栈里再push回来就行了。那么假如不能使用辅助栈,数组等空间为O(n)的数据结构,只使用O(1)的空间复杂度即只能有常数个变量,怎么实现将栈... 阅读全文

posted @ 2014-04-15 13:34 Allen Blue 阅读(3810) 评论(7) 推荐(1) 编辑

2014年4月13日

【LeetCode练习题】Combination Sum

摘要: Combination SumGiven a set of candidate numbers (C) and a target number (T), find all unique combinations inCwhere the candidate numbers sums toT.Thes... 阅读全文

posted @ 2014-04-13 21:19 Allen Blue 阅读(270) 评论(0) 推荐(0) 编辑

【LeetCode练习题】Minimum Depth of Binary Tree

摘要: Minimum Depth of Binary TreeGiven a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root... 阅读全文

posted @ 2014-04-13 16:31 Allen Blue 阅读(143) 评论(0) 推荐(0) 编辑

【LeetCode练习题】Maximum Depth of Binary Tree

摘要: Maximum Depth of Binary TreeGiven a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root ... 阅读全文

posted @ 2014-04-13 15:58 Allen Blue 阅读(195) 评论(0) 推荐(0) 编辑

2014年4月12日

【LeetCode练习题】Reverse Words in a String

摘要: Reverse Words in a StringGiven an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".Clarification:What constitutes a word?A sequence of non-space characters constitutes a word.Could the input string contain leading or t 阅读全文

posted @ 2014-04-12 21:00 Allen Blue 阅读(232) 评论(0) 推荐(0) 编辑

【LeetCode练习题】Minimum Path Sum

摘要: Minimum Path SumGiven amxngrid filled with non-negative numbers, find a path from top left to bottom right whichminimizesthe sum of all numbers along its path.Note:You can only move either down or right at any point in time.还是DP问题,给定一个m*n的二维数组,每一个值都是非负数。问从起点(左上角)到终点(右下角)的一条路径上所有的数加起来的和最小是多少?解题思路:参考 阅读全文

posted @ 2014-04-12 18:26 Allen Blue 阅读(373) 评论(0) 推荐(0) 编辑

【LeetCode练习题】Swap Nodes in Pairs

摘要: Swap Nodes in PairsGiven a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4, you should return the list as2->1->4->3.Your algorithm should use only constant space. You maynotmodify the values in the list, only nodes itself can be changed.相邻 阅读全文

posted @ 2014-04-12 17:16 Allen Blue 阅读(254) 评论(0) 推荐(0) 编辑

2014年4月11日

【LeetCode练习题】Unique Paths II

摘要: Unique Paths IIFollow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space is marked as1and0respectively in the grid.For example,There is one obstacle in the middle of a 3x3 grid as illustrated below.[ 阅读全文

posted @ 2014-04-11 21:45 Allen Blue 阅读(468) 评论(0) 推荐(0) 编辑

导航