1 2 3 4 5 ··· 20 下一页
摘要: ''' 1 4 3 4 5 6 5 r y b b r b b ''' def func(cards): n = len(cards) matrix = [[0 for _ in range(n)] for _ in range(n)] for i in range(n): for j in ran 阅读全文
posted @ 2022-08-26 21:38 Ray_chen 阅读(34) 评论(0) 推荐(0) 编辑
摘要: ''' 有效括号: 左括号必须以正确的顺序闭合 正确【】{} () 错误 [{]}] ''' class Solution: def is_valid(self,s): dic = {'(':')','[':']','{':'}'} stack = [] for i in s: if i in di 阅读全文
posted @ 2022-08-25 23:27 Ray_chen 阅读(35) 评论(0) 推荐(0) 编辑
摘要: ''' 长木板长度 longer,短木板长度 shorter,一共有k长木板,可以拼成的木板长度区间是多少? ''' class Solution: def diving_board(self,shorter,longer,k): if k == 0: return [] ans = [] minl 阅读全文
posted @ 2022-08-25 23:12 Ray_chen 阅读(19) 评论(0) 推荐(0) 编辑
摘要: ''' 1 / \ 2 3 12 + 13 = 25 ''' class TreeNode: def __init__(self,val): self.val = val self.left = None self.right = None class Solution: def sum_numbe 阅读全文
posted @ 2022-08-25 22:59 Ray_chen 阅读(19) 评论(0) 推荐(0) 编辑
摘要: ''' 1 / \ 2 3 / \ 4 5 ''' class TreeNode: def __init__(self,val): self.val = val self.left = None self.right = None # 深度优先-先序遍历 def dfs_pre(node): if 阅读全文
posted @ 2022-08-25 22:45 Ray_chen 阅读(13) 评论(0) 推荐(0) 编辑
摘要: # bfs & dfs graph = { "A":["B","C"], "B":["A","C","D"], "C":["A","B","D","E"], "D":["B","C","E","F"], "E":["C&q 阅读全文
posted @ 2022-08-25 20:32 Ray_chen 阅读(10) 评论(0) 推荐(0) 编辑
摘要: 基础版 青蛙一次可以跳1级或者2级台阶,问跳到N级有多少种跳法 class Solution: def jumpFloor(self,n): if n < 1: return 0 if n == 1 or n == 2: return n a = 1 b = 2 tmp = 1 for i in r 阅读全文
posted @ 2022-08-24 23:14 Ray_chen 阅读(22) 评论(0) 推荐(0) 编辑
摘要: 给你一个有序列表(升序),一个目标值。写代码返回列表中和为目标值的2个数的下标(该组合唯一) input [2,7,11,15], t = 18 output 1,2 双指针法 class Solution: def two_sum(self,nums,t): left = 0 right = le 阅读全文
posted @ 2022-08-24 22:58 Ray_chen 阅读(10) 评论(0) 推荐(0) 编辑
摘要: `# -- coding:utf-8 -- 功能:日志模块封装 import time import logging from logging import handlers from pathlib import Path class GetLogger(object): """ 日志封装类 "" 阅读全文
posted @ 2022-04-21 20:36 Ray_chen 阅读(28) 评论(0) 推荐(0) 编辑
摘要: #!/bin/bash echo " 1) 安装/管理/卸载" echo " 2) 创建用户" echo " 3) 查看用户" echo " 4) 删除所有用户" echo " 5) 退出" read -p "请选择:" choose case $choose in 1|"") echo " 1) 阅读全文
posted @ 2021-03-05 10:02 Ray_chen 阅读(7) 评论(0) 推荐(0) 编辑
1 2 3 4 5 ··· 20 下一页