上一页 1 2 3 4 5 6 7 ··· 9 下一页

2014年5月7日

[LeetCode] 接雨水,题 Trapping Rain Water

摘要: 这题放上来是因为自己第一回见到这种题,觉得它好玩儿 =)Trapping Rain WaterGivennnon-negative integers representing an elevation map where the width of each bar is 1, compute how... 阅读全文

posted @ 2014-05-07 10:26 Felix Fang 阅读(11676) 评论(2) 推荐(0) 编辑

2014年5月6日

[LeetCode] 大数问题,相加和相乘,题 Multiply Strings

摘要: Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and are non-nega... 阅读全文

posted @ 2014-05-06 11:06 Felix Fang 阅读(876) 评论(0) 推荐(0) 编辑

2014年5月5日

[LeetCode][Facebook面试题] 通配符匹配和正则表达式匹配,题 Wildcard Matching

摘要: 开篇通常的匹配分为两类,一种是正则表达式匹配,pattern包含一些关键字,比如'*'的用法是紧跟在pattern的某个字符后,表示这个字符可以出现任意多次(包括0次)。另一种是通配符匹配,我们在操作系统里搜索文件的时候,用的就是这种匹配。比如 "*.pdf",'*'在这里就不再代表次数,而是通配符... 阅读全文

posted @ 2014-05-05 13:16 Felix Fang 阅读(8727) 评论(0) 推荐(0) 编辑

2014年5月4日

[LeetCode] string整体做hash key,窗口思想复杂度O(n)。附来自LeetCode的4例题(标题有字数限制,写不下所有例题题目 T.T)

摘要: 引言在字符串类型的题目中,常常在解题的时候涉及到大量的字符串的两两比较,比如要统计某一个字符串出现的次数。如果每次比较都通过挨个字符比较的方式,那么毫无疑问是非常占用时间的,因此在一些情况下,我们可以将字符串本身作为hashmap的key,往往会大大节省时间。这篇博文中涉及的另一个技巧,是使用窗口的... 阅读全文

posted @ 2014-05-04 10:33 Felix Fang 阅读(1282) 评论(0) 推荐(0) 编辑

2014年5月3日

[LeetCode] “全排列”问题系列(一) - 用交换元素法生成全排列及其应用,例题: Permutations I 和 II, N-Queens I 和 II,数独问题

摘要: 一、开篇Permutation,排列问题。这篇博文以几道LeetCode的题目和引用剑指offer上的一道例题入手,小谈一下这种类型题目的解法。二、上手最典型的permutation题目是这样的:Given a collection of numbers, return all possible p... 阅读全文

posted @ 2014-05-03 22:56 Felix Fang 阅读(6999) 评论(1) 推荐(0) 编辑

2014年4月28日

动态规划小结 - 一维动态规划 - 时间复杂度 O(n),题 [LeetCode] Jump Game,Decode Ways

摘要: 引言一维动态规划根据转移方程,复杂度一般有两种情况。func(i) 只和 func(i-1)有关,时间复杂度是O(n),这种情况下空间复杂度往往可以优化为O(1)func(i) 和 func(1~i-1)有关,时间复杂度是O(n*n),这种情况下空间复杂度一般无法优化,依然为O(n)本篇讨论第一种情... 阅读全文

posted @ 2014-04-28 06:35 Felix Fang 阅读(8219) 评论(0) 推荐(0) 编辑

2014年4月27日

[LeetCode] Merge Interval系列,题:Insert Interval,Merge Intervals

摘要: Interval的合并时比较常见的一类题目,网上的Amazon面经上也有面试这道题的记录。这里以LeetCode上的例题做练习。Merge IntervalsGiven a collection of intervals, merge all overlapping intervals.For ex... 阅读全文

posted @ 2014-04-27 06:08 Felix Fang 阅读(580) 评论(0) 推荐(0) 编辑

2014年4月23日

[LeetCode] Simplify Path,文件路径简化,用栈来做

摘要: Given an absolute path for a file (Unix-style), simplify it.For example,path="/home/", =>"/home"path="/a/./b/../../c/", =>"/c"click to show corner cas... 阅读全文

posted @ 2014-04-23 04:23 Felix Fang 阅读(419) 评论(0) 推荐(0) 编辑

2014年4月22日

[LeetCode] Sort Colors 对于元素取值有限的数组,只遍历一遍的排序方法

摘要: Given an array withnobjects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, wh... 阅读全文

posted @ 2014-04-22 11:10 Felix Fang 阅读(3610) 评论(0) 推荐(0) 编辑

2014年4月20日

[LeetCode] Largest Rectangle in Histogram O(n) 解法详析, Maximal Rectangle

摘要: Largest Rectangle in HistogramGivennnon-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of l... 阅读全文

posted @ 2014-04-20 13:06 Felix Fang 阅读(12363) 评论(3) 推荐(0) 编辑

上一页 1 2 3 4 5 6 7 ··· 9 下一页

导航