牛客err
牛客err
全部文章
分类
题解(4)
归档
标签
去牛客网
登录
/
注册
牛客err的博客
TA的专栏
20篇文章
0人订阅
数据结构练习
20篇文章
132人学习
全部文章
(共162篇)
题解 | #最长回文子串#
class Solution: def getLongestPalindrome(self, A: str) -> int: n = len(A) if n < 2: return n max_length...
2024-08-28
0
80
题解 | #最长上升子序列(一)#
class Solution: def LIS(self, arr: List[int]) -> int: n = len(arr) if n == 0: return 0 dp = [1] * n # 初始化...
2024-08-28
0
85
题解 | #兑换零钱(一)#
class Solution: def minMoney(self, arr: List[int], aim: int) -> int: dp = [float('inf')]*(aim+1) dp[0] = 0 for coin in...
2024-08-28
0
78
题解 | #把数字翻译成字符串#
class Solution: def solve(self, nums: str) -> int: n = len(nums) if n == 0: return 0 dp = [0] * (n + 1) ...
2024-08-27
0
96
题解 | #矩阵的最小路径和#
class Solution: def minPathSum(self, matrix: List[List[int]]) -> int: if not matrix or not matrix[0]: return 0 n, ...
2024-08-27
0
87
题解 | #不同路径的数目(一)#
class Solution: def uniquePaths(self, m: int, n: int) -> int: dp = [[0] * n for _ in range(m)] # 初始化第一行和第一列 for i in r...
2024-08-27
0
80
题解 | #最长公共子串#
class Solution: def LCS(self , str1: str, str2: str) -> str: if len(str1) < len(str2): # 从长度大的字符串开始遍历 str1, str2 = str2,...
2024-08-27
0
101
题解 | #最长公共子序列(二)#
class Solution: def LCS(self, s1: str, s2: str) -> str: m, n = len(s1), len(s2) # 创建一个二维数组来存储最长公共子序列的长度 dp = [[0] * (n ...
2024-08-27
0
86
题解 | #最小花费爬楼梯#
class Solution: def minCostClimbingStairs(self, cost: List[int]) -> int: n = len(cost) dp = [0]*n dp[0] = cost[0] ...
2024-08-27
0
82
题解 | #跳台阶#
class Solution: def jumpFloor(self , number: int) -> int: if number == 1: return 1 dp = [0]*number # 其...
2024-08-27
0
95
首页
上一页
1
2
3
4
5
6
7
8
9
10
下一页
末页