摘要: 博客地址:https://www.cnblogs.com/zylyehuo/ # -*- coding: utf-8 -*- def activity_selection(a): res = [a[0]] for i in range(1, len(a)): if a[i][0] >= res[-1 阅读全文
posted @ 2023-08-19 10:52 zylyehuo 阅读(7) 评论(0) 推荐(0) 编辑
摘要: 博客地址:https://www.cnblogs.com/zylyehuo/ # -*- coding: utf-8 -*- from functools import cmp_to_key def xy_cmp(x, y): if x + y < y + x: return 1 # 表示 x>y 阅读全文
posted @ 2023-08-19 10:33 zylyehuo 阅读(8) 评论(0) 推荐(0) 编辑
摘要: 博客地址:https://www.cnblogs.com/zylyehuo/ # -*- coding: utf-8 -*- stuffs = [(60, 10), (100, 20), (120, 30)] # 每个商品元组表示(价格, 重量) stuffs.sort(key=lambda x: 阅读全文
posted @ 2023-08-18 23:04 zylyehuo 阅读(38) 评论(0) 推荐(0) 编辑
摘要: 博客地址:https://www.cnblogs.com/zylyehuo/ # -*- coding: utf-8 -*- t = [100, 50, 20, 5] def change(t, n): m = [0 for _ in range(len(t))] # m 为各面额纸币的张数 for 阅读全文
posted @ 2023-08-18 21:28 zylyehuo 阅读(7) 评论(0) 推荐(0) 编辑
摘要: 博客地址:https://www.cnblogs.com/zylyehuo/ bst.py # -*- coding: utf-8 -*- # 构造二叉树 class BiTreeNode: def __init__(self, data): self.data = data self.lchild 阅读全文
posted @ 2023-08-18 20:12 zylyehuo 阅读(6) 评论(0) 推荐(0) 编辑
摘要: 博客地址:https://www.cnblogs.com/zylyehuo/ # -*- coding: utf-8 -*- # 构造二叉树 class BiTreeNode: def __init__(self, data): self.data = data self.lchild = None 阅读全文
posted @ 2023-08-18 12:52 zylyehuo 阅读(9) 评论(0) 推荐(0) 编辑
摘要: 博客地址:https://www.cnblogs.com/zylyehuo/ # -*- coding: utf-8 -*- from collections import deque class BiTreeNode: def __init__(self, data): self.data = d 阅读全文
posted @ 2023-08-18 10:51 zylyehuo 阅读(4) 评论(0) 推荐(0) 编辑
摘要: 博客地址:https://www.cnblogs.com/zylyehuo/ # -*- coding: utf-8 -*- class Node: # 链式存储 def __init__(self, name, type='dir'): self.name = name self.type = t 阅读全文
posted @ 2023-08-18 10:32 zylyehuo 阅读(5) 评论(0) 推荐(0) 编辑
摘要: 博客地址:https://www.cnblogs.com/zylyehuo/ # -*- coding: utf-8 -*- class LinkList: class Node: def __init__(self, item=None): self.item = item self.next = 阅读全文
posted @ 2023-08-17 22:48 zylyehuo 阅读(9) 评论(0) 推荐(0) 编辑
摘要: 博客地址:https://www.cnblogs.com/zylyehuo/ # -*- coding: utf-8 -*- class Node: def __init__(self, item): self.item = item self.next = None # 头插法 def creat 阅读全文
posted @ 2023-08-17 15:51 zylyehuo 阅读(4) 评论(0) 推荐(0) 编辑
摘要: 博客地址:https://www.cnblogs.com/zylyehuo/ # -*- coding: utf-8 -*- from collections import deque maze = [ [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 1, 0, 阅读全文
posted @ 2023-08-17 14:29 zylyehuo 阅读(7) 评论(0) 推荐(0) 编辑
摘要: 博客地址:https://www.cnblogs.com/zylyehuo/ # -*- coding: utf-8 -*- maze = [ [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 1, 0, 0, 0, 1, 0, 1], [1, 0, 0, 1, 0 阅读全文
posted @ 2023-08-17 13:45 zylyehuo 阅读(16) 评论(0) 推荐(0) 编辑
摘要: 博客地址:https://www.cnblogs.com/zylyehuo/ # -*- coding: utf-8 -*- from collections import deque def tail(n): # n:指定输出文件中最后几行 with open('test.txt', 'r') a 阅读全文
posted @ 2023-08-17 13:26 zylyehuo 阅读(5) 评论(0) 推荐(0) 编辑
摘要: 博客地址:https://www.cnblogs.com/zylyehuo/ # -*- coding: utf-8 -*- from collections import deque q = deque([1,2,3,4,5], 5) q.append(6) # 队尾进队 print(q.popl 阅读全文
posted @ 2023-08-17 13:25 zylyehuo 阅读(6) 评论(0) 推荐(0) 编辑
摘要: 博客地址:https://www.cnblogs.com/zylyehuo/ # -*- coding: utf-8 -*- class Queue: def __init__(self, size=100): self.queue = [0 for _ in range(size)] self.s 阅读全文
posted @ 2023-08-17 13:15 zylyehuo 阅读(5) 评论(0) 推荐(0) 编辑