上一页 1 ··· 6 7 8 9 10 11 12 13 14 下一页
摘要: 自己写的递归: class Solution: def __init__(self): self.res_list=list() def inorderTraversal(self, root) : if root: if root==None: return else: self.inorderT 阅读全文
posted @ 2024-02-03 17:31 Junior_bond 阅读(5) 评论(0) 推荐(0)
摘要: 二叉树 class Node(object): def __init__(self,val,lchild=None,rchild=None): self.val=val self.lchild=lchild self.rchild=rchild class Tree(object): def __i 阅读全文
posted @ 2024-02-03 16:57 Junior_bond 阅读(14) 评论(0) 推荐(0)
摘要: 单循环链表 class ListNode: def __init__(self,val,next=None): self.val=val self.next=next class SingleLoopLinkList: def __init__(self,node=None): self.__hea 阅读全文
posted @ 2024-02-02 22:17 Junior_bond 阅读(11) 评论(0) 推荐(0)
摘要: 双链表 class ListNode: def __init__(self,val,prev=None,next=None): self.val=val self.prev=prev self.next=next class DoubleLinkList: def __init__(self,nod 阅读全文
posted @ 2024-02-02 14:45 Junior_bond 阅读(16) 评论(0) 推荐(0)
摘要: 使用 nums1[:m + n] = nums1_new 时,这是在原地修改 nums1 列表。具体来说,这个语句使用切片将 nums1 中前 m + n 个元素替换为 nums1_new 中的元素。这样做的结果是,nums1 的原始内存空间被修改,而不是创建一个新的列表对象。 使用 nums1 = 阅读全文
posted @ 2024-02-01 16:51 Junior_bond 阅读(16) 评论(0) 推荐(0)
摘要: class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class Solution: def deleteDuplicates(self, head: Optional[ListNo 阅读全文
posted @ 2024-01-31 22:45 Junior_bond 阅读(6) 评论(0) 推荐(0)
摘要: class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class SingleLinkList: def __init__(self,node=None): self.__head= 阅读全文
posted @ 2024-01-31 21:29 Junior_bond 阅读(13) 评论(0) 推荐(0)
摘要: 斐波那契数列: class Solution: def climbStairs(self, n: int) -> int: if n==1: return 1 s=[0]*(n+1) s[1]=1 s[2]=2 for i in range(3,n+1): s[i]=s[i-1]+s[i-2] re 阅读全文
posted @ 2024-01-30 19:54 Junior_bond 阅读(7) 评论(0) 推荐(0)
摘要: 暴力搜索 class Solution: def mySqrt(self, x: int) -> int: if x>=100 and x<10000: i=10 elif x>=10000 and x<1000000: i=100 elif x>=1000000: i=1000 else: i=0 阅读全文
posted @ 2024-01-25 10:31 Junior_bond 阅读(6) 评论(0) 推荐(0)
摘要: 自己写的 class Solution: def addBinary(self, a: str, b: str) -> str: a_len=len(a) b_len=len(b) if a_len<b_len: temp=b b=a a=temp a_len = len(a) b_len = le 阅读全文
posted @ 2024-01-24 14:47 Junior_bond 阅读(11) 评论(0) 推荐(0)
上一页 1 ··· 6 7 8 9 10 11 12 13 14 下一页