摘要: 1. 单词搜索 给定一个 m x n 二维字符网格 board 和一个字符串单词 word 。如果 word 存在于网格中,返回 true ;否则,返回 false 。 class Solution: def exist(self, board: List[List[str]], word: str 阅读全文
posted @ 2024-09-23 02:26 WindMay 阅读(3) 评论(0) 推荐(0) 编辑
摘要: 1. 组合 给定两个整数 n 和 k,返回范围 [1, n] 中所有可能的 k 个数的组合。 class Solution: def combine(self, n: int, k: int) -> List[List[int]]: def backtrack(start, path): if le 阅读全文
posted @ 2024-09-23 02:22 WindMay 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 1. 颜色分类 给定一个包含红色、白色和蓝色、共 n 个元素的数组 nums ,原地 对它们进行排序,使得相同颜色的元素相邻,并按照红色、白色、蓝色顺序排列。 使用整数 0、 1 和 2 分别表示红色、白色和蓝色。 不使用库内置的 sort 函数的情况下解决这个问题。 class Solution: 阅读全文
posted @ 2024-09-23 02:20 WindMay 阅读(0) 评论(0) 推荐(0) 编辑