
LeetCode
热衷开源的宝藏Boy
努力践行将学习的本质与机器学习完美结合!
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
LeetCode:将两个元素为字符串的列表合成以中文为健,英文为值,并且英文首字母大写的字典
LeetCode题目有两个列表的字符串str1 = [“中文”, “苹果”, “pear”] , str2 = [“English”, “apple”, “梨”]以中文为健,英文为值,并且英文首字母大写def is_English(word): '''判断是否为英文''' for i in word: if "a" <= i <= "z" or "A" <= i <= "Z": pass else:原创 2021-03-29 08:36:34 · 313 阅读 · 1 评论 -
快乐数
时间超出限制原创 2020-04-15 15:32:25 · 113 阅读 · 0 评论 -
字符串中的第一个唯一字符
原创 2020-04-15 14:33:39 · 170 阅读 · 0 评论 -
存在重复元素
原创 2020-04-15 14:10:43 · 95 阅读 · 0 评论 -
计数质数
原创 2020-04-15 13:50:35 · 100 阅读 · 0 评论 -
二叉树的中序遍历
原创 2020-04-15 13:08:43 · 128 阅读 · 0 评论 -
鸡蛋掉落
原题目原创 2020-04-11 14:00:53 · 116 阅读 · 0 评论 -
1~n整数中出现1的次数
class Solution: def countDigitOne(self, n: int) -> int: if n<=0:return 0 str_n=str(n) high=int(str_n[0]) base=10**(len(str_n)-1) last=n%base ...原创 2020-04-10 10:22:36 · 146 阅读 · 0 评论 -
括号生成深度搜索方法
深度搜索原创 2020-04-09 15:32:10 · 199 阅读 · 0 评论 -
字符串转化整数状态自动机
参考1参考2正则表达式解法状态自动机INT_MAX = 2 ** 31 - 1INT_MIN = -2 ** 31class Automaton: def __init__(self): self.state = 'start' self.sign = 1 self.ans = 0 self.table...转载 2020-04-09 14:09:49 · 293 阅读 · 1 评论 -
最小的k个数
上面方法(冒泡)超时原创 2020-03-20 21:16:52 · 111 阅读 · 0 评论 -
最长回文串
原创 2020-03-19 11:17:10 · 98 阅读 · 0 评论 -
矩形重叠
原创 2020-03-18 17:56:09 · 100 阅读 · 0 评论 -
拼写单词
原创 2020-03-17 23:17:34 · 104 阅读 · 0 评论 -
岛屿的最大面积
原创 2020-03-16 15:21:37 · 100 阅读 · 0 评论 -
字符串压缩
原创 2020-03-16 14:55:03 · 126 阅读 · 0 评论 -
字符串的最大公因子
原创 2020-03-12 10:48:00 · 119 阅读 · 0 评论 -
Leetcode顺时针打印矩阵
https://leetcode-cn.com/problems/shun-shi-zhen-da-yin-ju-zhen-lcof/原创 2020-03-11 22:28:10 · 126 阅读 · 0 评论 -
Leetcode将数组分成和相等的三个部分
第一次在Leetcode上写出这么高质量的代码出来,纪念一下。哈哈哈哈原创 2020-03-11 15:25:17 · 243 阅读 · 0 评论 -
二叉树的直径
https://leetcode-cn.com/problems/diameter-of-binary-tree/原创 2020-03-10 10:03:27 · 211 阅读 · 0 评论 -
不同路径-动态规划自底向上解法
动态规划一般解法步骤1 写出状态转移方程2 写出最底层状态3 自下而上遍历原创 2020-03-09 16:08:32 · 327 阅读 · 0 评论 -
动态规划 爬楼梯
状态转移函数代码此方法具有优化时间复杂度,但空间复杂度较大原创 2020-03-09 14:35:56 · 197 阅读 · 0 评论 -
LeetCode买卖股票的最佳时机
超过时间限制的解法原创 2020-03-09 13:36:32 · 164 阅读 · 0 评论 -
动态规划-自顶向下
核心思想每一层为一个步骤。原创 2020-03-09 09:53:10 · 210 阅读 · 0 评论 -
零钱兑换-动态规划详解(自下而上)
def coinChange(self, coins: List[int], amount: int) -> int: df = [float('inf')]*(amount+1) df[0] = 0 for coin in coins: for n in range(coin,amount+1): ...原创 2020-03-08 20:41:59 · 374 阅读 · 0 评论 -
分糖果
class Solution: def distributeCandies(self, candies: int, num_people: int) -> List[int]: List = [0]*num_people flag = 1 num = 1 while flag: for i i...原创 2020-03-07 10:38:08 · 93 阅读 · 0 评论 -
二叉树寻路
class Solution: def pathInZigZagTree(self, label: int) -> List[int]: res = [] while label != 1: res.append(label) label >>= 1 # 这里我采用异...原创 2020-03-07 10:35:29 · 243 阅读 · 0 评论 -
Z字形变换
class Solution: def convert(self, s: str, numRows: int) -> str: if numRows==1:return s res = ['' for _ in range(numRows)] i,flag = 0,-1 for c in s: ...原创 2020-03-07 10:32:52 · 109 阅读 · 0 评论 -
峰与谷
class Solution: def wiggleSort(self, nums: List[int]) -> None: """ Do not return anything, modify nums in-place instead. """ for i in range(len(nums)-1): ...原创 2020-03-07 10:28:50 · 325 阅读 · 1 评论 -
赎金信
class Solution: def canConstruct(self, ransomNote: str, magazine: str) -> bool: a = list(ransomNote);b = list(magazine) try: for i in a: b.remove(i...原创 2020-03-07 10:25:03 · 147 阅读 · 0 评论 -
有效的数独
class Solution: def isValidSudoku(self, board: List[List[str]]) -> bool: col = [[] for _ in range(9)] raw = [[] for _ in range(9)] block = [[] for _ in range(9)] ...原创 2020-03-07 10:22:09 · 143 阅读 · 0 评论 -
和为s的连续队列
import queueclass MaxQueue: def __init__(self): self.deque = queue.deque() def max_value(self) -> int: return max(self.deque) if self.deque else -1 def push_back(se...原创 2020-03-07 10:03:18 · 110 阅读 · 0 评论 -
队列的最大值
import queueclass MaxQueue: def __init__(self): self.deque = queue.deque() def max_value(self) -> int: return max(self.deque) if self.deque else -1 def push_back(se...原创 2020-03-07 09:58:31 · 109 阅读 · 0 评论