bytedancers
bytedancers
全部文章
题解
面经(1)
归档
标签
去牛客网
登录
/
注册
bytedancers的博客
全部文章
/ 题解
(共7篇)
题解 | #数组中只出现一次的数(其它数出现k次)#
python只能调用ctypes来做吹了位运算的结果了 class Solution: def foundOnceNumber(self , arr , k ): # write code here res = 0 for i in range...
2021-09-05
0
312
题解 | #最长递增子序列#
python使用bisect和patient sort, 借助pre记录每个位置的前驱 import bisect class Solution: def LIS(self , arr ): stack = [0] pre = [-1] * len(arr) ...
2021-09-05
1
375
题解 | #链表中的节点每k个一组翻转#
最短python递归版本,自解释 class Solution: def reverseKGroup(self , head , k ): t = head for i in range(k): if t is None: ...
python
2021-08-01
3
454
patient sort + 记录前驱位置
class Solution: def LIS(self, arr): stack = [0] n = len(arr) pre = [-1] * n for i in range(1, n): if a...
python
LIS
快手
2021-04-01
3
615
小美的新游戏-DFS
使用增量字典减少代码量和判断流程python可能超过最大递归深度,需要手动设置增大递归深度 import sys sys.setrecursionlimit(100000) n, m, P, Q = map(int, input().strip().split()) grid = [] for i ...
2021-03-13
1
609
小美的美丽树-DFS
DFS即可 from collections import defaultdict N, K = map(int, input().strip().split()) tree = list(map(int, input().strip().split())) adj = defaultdict(l...
2021-03-13
1
790
两个指针即可
T = int(input().strip()) import heapq def find_next(tables, i, num): tlen = len(tables) while i < tlen and tables[i] != num: i += 1...
2021-03-12
1
552