dthcle_
dthcle_
全部文章
分类
归档
标签
去牛客网
登录
/
注册
dthcle_的博客
全部文章
(共42篇)
题解 | 找出字符串中第一个只出现一次的字符
第一次遍历:计数第二次遍历:记录index并比较出最小值 s = input().strip() alphabet = "zxcvbnmasdfghjklqwertyuiop" counter_dict = {} for each in alphabet: count...
2026-01-12
0
22
题解 | 高精度整数加法
人生苦短,我用python~ # a = int(input().strip()) # b = int(input().strip()) # print(a+b) a = input().strip() b = input().strip() if len(a) > len(b): ...
2026-01-12
0
19
题解 | 挑7
注意题干,结果是不包含0但包含n的 import sys def check_7(s: int) -> bool: if s % 7 == 0: return True elif "7" in str(s): return ...
2026-01-12
0
20
题解 | 计算字符串的编辑距离
注意动态规划的时候,dp行下标列下标的含义和字符串对比的长度! s = input().strip() t = input().strip() dp = [[0] * (len(s)+1) for _ in range(len(t)+1)] # 初始化 for j in range(len(s)+...
2026-01-12
0
19
题解 | 四则运算
魔道不削能玩? import sys for line in sys.stdin: a = line.strip() a = a.replace("{", "(").replace("}", ")")....
2026-01-08
0
14
题解 | 从单向链表中删除指定值的节点
nums = list(map(int, input().split())) n = nums.pop(0) head = nums.pop(0) chain = [head] while len(nums) > 1: num = nums.pop(0) base = nu...
2026-01-08
0
13
题解 | 名字的漂亮度
带变量的排序。最后都多余带key值,字符串解析完了后,直接把counter倒序排序乘过去就行了。 t = int(input().strip()) for _ in range(t): name = input().strip() alphabet = {} for eac...
2026-01-08
0
16
题解 | 迷宫问题
栈的基本用法 from collections import deque h, w = map(int, input().split()) map_graph = [] for _ in range(h): map_graph.append(list(map(int, input().s...
2026-01-08
0
11
题解 | 字符串合并处理
翻转的时候注意会多左移一次,因此需要右移一位来抵消。 u = "".join(input().strip().split()) u_1 = u[0::2] # 奇数位 u_1 = sorted(u_1, key=lambda x:ord(x)) u_2 = u[1::2] ...
2026-01-07
0
25
题解 | 识别有效的IP地址和掩码并进行分类统计
千万!不要!尝试写合法子网掩码的生成式!老老实实一个一个写左移!查生成式BUG查了半小时! import sys code_list = [ 0b0, 0b1 << 7, 0b11 << 6, 0b111 << 5, 0b...
2026-01-07
0
19
首页
上一页
1
2
3
4
5
下一页
末页