题解列表

筛选

2999: 牛吃牧草

摘要:解题思路:#设一头牛一天吃n份草#原有s份草#每天增加a份草得方程s+20a=15n*20   s+10a=20n*10解得a/n=(15*20-20*10)/(20-10)=10注意事项:参考代码:……

成绩排序(python匿名函数解法)

摘要:解题思路:思路不难,python创建一个列表存储姓名和成绩,然后再将所有人的成绩存储到一个列表当中,直接用sort函数搭配lambda匿名函数对成绩和名字的字典序进行排序,再用for循环一一输出即可注……

车厢调度(python)

摘要:解题思路:注意事项:参考代码:def trainSchedule(n, order):    stack = []    next_car = 1        for car in order:  ……

合并果子(python)

摘要:解题思路:注意事项:参考代码:import heapqdef mergeFruits(fruits):    heap = []    for fruit in fruits:        heap……

二叉树遍历(python)

摘要:解题思路:注意事项:参考代码:# 定义树节点的数据结构class TreeNode:    def __init__(self, val):        self.val = val        ……

求后序遍历

摘要:解题思路:注意事项:参考代码:# 定义树节点的数据结构class TreeNode:    def __init__(self, val):        self.val = val        ……

求后序遍历(python)

摘要:解题思路:注意事项:参考代码:def build_tree(preorder, inorder):    if not preorder or not inorder:        return N……

单词查找树(python)

摘要:解题思路:注意事项:参考代码:class TrieNode:    def __init__(self):        self.children = {}        self.is_end_o……

使用滑动窗口来解决

摘要:解题思路:注意事项:参考代码:n = int(input()) a = input().split() s = [] ans = 0  # 初始化收集的雪花数量 l, r = 0, 0  # ……