上一页 1 ··· 11 12 13 14 15 16 17 18 19 ··· 21 下一页

2016年5月29日

Trapping Rain Water

摘要: Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. 阅读全文

posted @ 2016-05-29 22:35 Sheryl Wang 阅读(265) 评论(0) 推荐(0) 编辑

Container With Most Water

摘要: Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpo 阅读全文

posted @ 2016-05-29 12:19 Sheryl Wang 阅读(226) 评论(0) 推荐(0) 编辑

2016年5月28日

python 类变量和实例变量

摘要: python的类变量和实例变量,顾名思义,类变量是指跟类的变量,而实例变量,指跟类的具体实例相关联的变量,具体体现为self.x 等。实际要注意的类变量和实例变量之间的关联。和类方法可以通过类也可以通过实例访问类似,类变量既可以通过实例也可以通过类来访问。 来看举例: class Person: n 阅读全文

posted @ 2016-05-28 16:34 Sheryl Wang 阅读(2926) 评论(1) 推荐(0) 编辑

python静态方法和类方法 @staticmethod @classmethod

摘要: python一共有三类方法: 静态方法,类方法和实例方法。 首先看一个例子: 1.可以看到,实例方法需要self指向实例本身。 2.装饰器@classmethod可以创建只在类中运行而不在实例中运行的方法. 如果我们想让方法不在实例中运行,可以这样做。代码来自知乎: class Kls(object 阅读全文

posted @ 2016-05-28 16:06 Sheryl Wang 阅读(337) 评论(0) 推荐(0) 编辑

2016年5月26日

Palindrome Partitioning II

摘要: Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning 阅读全文

posted @ 2016-05-26 22:16 Sheryl Wang 阅读(129) 评论(0) 推荐(0) 编辑

Longest Common Substring

摘要: 给出两个字符串,找到最长公共子串,并返回其长度。 注意事项 子串的字符应该连续的出现在原字符串中,这与子序列有所不同。 Lintcode上的一道题目,非常经典,需要找到最长的连续公共子串的长度。 因为有两个序列且前后顺序不可以打乱,所以为双序列问题。 这种问题比较重要的是定义状态。这里将状态f[i] 阅读全文

posted @ 2016-05-26 15:37 Sheryl Wang 阅读(173) 评论(0) 推荐(0) 编辑

Longest Increasing Subsequence

摘要: Given an unsorted array of integers, find the length of longest increasing subsequence. For example,Given [10, 9, 2, 5, 3, 7, 101, 18],The longest inc 阅读全文

posted @ 2016-05-26 14:43 Sheryl Wang 阅读(122) 评论(0) 推荐(0) 编辑

2016年5月25日

Word Break

摘要: Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words. For 阅读全文

posted @ 2016-05-25 21:38 Sheryl Wang 阅读(181) 评论(0) 推荐(0) 编辑

Distinct Subsequences

摘要: Given a string S and a string T, count the number of distinct subsequences of T in S. A subsequence of a string is a new string which is formed from t 阅读全文

posted @ 2016-05-25 20:31 Sheryl Wang 阅读(160) 评论(0) 推荐(0) 编辑

2016年5月24日

Edit Distance

摘要: Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.) You have 阅读全文

posted @ 2016-05-24 12:13 Sheryl Wang 阅读(208) 评论(0) 推荐(0) 编辑

上一页 1 ··· 11 12 13 14 15 16 17 18 19 ··· 21 下一页

导航