卡卡西chi
卡卡西chi
全部文章
分类
题解(8)
归档
标签
去牛客网
登录
/
注册
卡卡西chi的博客
全部文章
(共8篇)
题解 | #最大数# 不使用字符串拼接
采用冒泡排序,分情况比较 # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # 最大数 # @param nums int整型一维数组 # @return string字符串 # class Solution: def solve(self , nums: ...
Python3
双指针
2022-03-03
0
176
题解 | #表达式求值# 不使用eval函数
import re chars = input() chars = re.sub(r"([-+*/()])", r" \1 ", chars) tmp = chars.split() tokens = [] #处理负数 f = False for i, x in enumerate(tmp): ...
Python3
2021-12-26
11
1110
题解 | #火车进站#
利用“进出”操作的排列 while True: try: n = int(input()) trains = input().split() perm = [[] for _ in range(n+1)] perm[1] = ['ab'] for i in range(2, ...
Python3
2021-11-30
0
365
题解 | #MP3光标位置#
while True: try: n = int(input()) s = input() play_list = [i for i in range(1, n+1)] if n <= 4: top = 0 bottom = top + n - 1 this...
Python3
2021-11-30
0
245
题解 | #查找输入整数二进制中1的个数#
while True: try: n = int(input()) b = [int(i) for i in bin(n)[2:]] print(sum(b)) except: break
Python3
2021-11-30
0
203
题解 | #找出字符串中第一个只出现一次的字符#
遍历两次字符串 from collections import defaultdict while True: try: s = input() d = defaultdict(int) for c in s: d[c] += 1 flag = False for c ...
Python3
2021-11-30
0
222
题解 | #挑7#
list comprehension while True: try: n = int(input()) seven = [i for i in range(1, n+1) if i % 7 == 0 or '7' in str(i)] print(len(seven)) excep...
Python3
2021-11-23
0
174
题解 | #在字符串中找出连续最长的数字串#
两层循环 while True: try: s = input() l = len(s) max_ = 0 dic = {} for i, c in enumerate(s): if '0' <= c <= '9': k = i sub = ...
Python3
2021-11-23
0
276