牛客791761168号
牛客791761168号
全部文章
题解
归档
标签
去牛客网
登录
/
注册
牛客791761168号的博客
全部文章
/ 题解
(共5篇)
题解 | #字典序排列#
# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param n int整型 # @return int整型一维数组 # class Solution: def orderArray(self , n: int) -> List[int]:...
Python3
2022-03-31
4
372
题解 | #有重复项数字的全排列#
使用自带的全排列函数,去重后使用sorted进行字典序排序 from itertools import permutations class Solution: def permuteUnique(self , num: List[int]) -> List[List[int]]:...
Python3
2022-03-31
5
672
题解 | #【模板】哈夫曼编码#
import heapq import bisect 超时,不知道应该优化哪里了 def quick_sort(array, left, right): if left >= right: ...
Python3
贪心
2022-03-31
1
387
题解 | #活动安排#
使用最小堆排序任务集,贪心策略为每次加入和上一个活动时间不冲突的,结束时间最早的活动 import heapq n = int(input()) tasks = [] for _ in range(n): a, b = map(int, input...
Python3
贪心
2022-03-30
3
382
题解 | #坐标移动#
import re, sys for input_data in sys.stdin: steps_ori = input_data.split(';') steps = [x for x in steps_ori if re.match('[ASWD]{1}[0-9]{1,2}$', x)] co...
Python3
2022-02-13
0
283