![](https://img-blog.csdnimg.cn/20201014180756918.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
lintcode
Black Spur
这个作者很懒,什么都没留下…
展开
-
python之lintcode刷题:rotate string
def rotateString(s, offset): # write your code here str_length = len(s) str_new = s[str_length - offset:] + s[:str_length - offset] return str_newstr_old = 'abcdefgh'print(rotateSt...原创 2019-08-04 13:37:18 · 166 阅读 · 0 评论 -
python之lintcode刷题:two sun
给一个整数数组,找到两个数使得他们的和等于一个给定的数 target。你需要实现的函数twoSum需要返回这两个数的下标, 并且第一个下标小于第二个下标。注意这里下标的范围是 0 到 n-1。def twoSum(self, numbers, target): # write your code here for i in range(len(numbers))...原创 2019-08-04 14:15:11 · 120 阅读 · 0 评论 -
python之lintcode刷题:Narcissistic number
def su_mu(n): num_list = [] if n == 1: for demo in range(10 ** n): sum = 0 for i in range(1, n + 1): sum += int(str(demo)[i - 1]) ** n ...原创 2019-08-04 15:35:39 · 208 阅读 · 0 评论 -
python之lintcode刷题:single number
Single NumberGiven 2 * n + 1 numbers, every numbers occurs twice except one, find it.ExampleExample 1:Input:[1,1,2,2,3,4,4]Output:3Explanation:Only 3 appears onceExample 2:Input:[0,0,1]Outpu...原创 2019-08-05 21:19:55 · 119 阅读 · 0 评论 -
python之lintcode刷题:Find The Numbers II
Given two numbers A and B, find out all the numbers which are the multiple of 3 between A and B (including A and B). Return the sum of these numbers.代码:def getSum(A, B): # Write your code here ...原创 2019-08-05 22:44:55 · 196 阅读 · 0 评论 -
python之lintcode刷题: Unique Characters
Unique CharactersImplement an algorithm to determine if a string has all unique characters.def isUnique(str): # write your code here for i in range(len(str)): for j in range(i + 1,...原创 2019-08-09 21:20:10 · 213 阅读 · 0 评论 -
python之lintcode刷题: Reverse Words in a String
Reverse Words in a StringGiven an input string, reverse the string word by wordclass Solution: """ @param: s: A string @return: A string """ def reverseWords(self, s): ...原创 2019-08-09 21:34:20 · 218 阅读 · 0 评论