王涛eclipse
王涛eclipse
全部文章
题解
未归档(1)
归档
标签
去牛客网
登录
/
注册
王涛eclipse的博客
全部文章
/ 题解
(共11篇)
题解 | #构建乘积数组#
# -*- coding:utf-8 -*- class Solution: def multiply(self, A): # write code here B = [] A_copy = [] for i in range(...
2021-09-06
0
370
题解 | #剪绳子#
用归纳法发现,最大的分解都是有2,3组成。且有两个条件:1.3越多越好2.不能为了增加3而加入1 n/3余0:全为3余1:有两个2,其余全为3余2:有一个2,其余全为3 # -*- coding:utf-8 -*- class Solution: def cutRope(self, numb...
2021-09-05
0
263
题解 | #数组中重复的数字#
方法一:时间复杂度:O(n)花费时间:0.0010638000000000002集合使用方法 class Solution: def duplicate(self , numbers ): # write code here if len(numbers) ...
2021-09-05
0
332
题解 | #整数中1出现的次数(从1到n整数中1出现的次数)#
1.找位数2,看是从后面还是从前面找1 # -*- coding:utf-8 -*- class Solution: def NumberOf1Between1AndN_Solution(self, n): # write code here result =...
2021-09-04
0
320
题解 | #求1+2+3+...+n#
为啥下面的不行? # -*- coding:utf-8 -*- class Solution: def Sum_Solution(self, n): # write code here result = (n+1)*n/2 return res...
2021-08-31
0
230
题解 | #跳台阶扩展问题#
同普通青蛙跳一样用归纳法 # -*- coding:utf-8 -*- class Solution: def jumpFloorII(self, number): # write code here if number <= 0: ...
2021-08-31
0
242
题解 | #跳台阶#
归纳法:第一步:第一行是number值,第二行是步数,归纳完就是f(n) = f(n-1) + f(n-2)第二步:找循环,number = 3,需要循环1次。number = 4,需要循环2次... ...1 2 3 4 5 6 71 2 3 5 8 13 21 # -*- coding:utf...
2021-08-31
0
355
题解 | #斐波那契数列#
不使用递归: # -*- coding:utf-8 -*- class Solution: def Fibonacci(self, n): # write code here a =0 b = 1 i=0 if ...
2021-08-23
0
295
题解 | #从尾到头打印链表#
学习链表读取数据的方法 # -*- coding:utf-8 -*- # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: ...
2021-08-23
0
343
题解 | #替换空格#
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param s string字符串 # @return string字符串 # class Solution:...
2021-08-19
0
446
首页
上一页
1
2
下一页
末页