leetcode解题记录

本文汇总了数组、动态规划和字符串相关的LeetCode题目,包括旋转图像、螺旋矩阵、不同路径II、矩阵置零、搜索二维矩阵、颜色分类等经典问题。讲解了多种解题策略,如滚动数组思想、动态规划、DFS模板等,并提供了详细解法和链接。适合提升编程技能和算法理解。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

目录

 

 

目录

数组

动态规划

字符串


 


数组

1.leetcode 48 旋转图像

https://leetcode-cn.com/problems/rotate-image/solution/li-kou-48xiao-bai-du-neng-kan-dong-de-fang-fa-zhu-/

https://leetcode-cn.com/problems/rotate-image/solution/xuan-zhuan-tu-xiang-by-leetcode/

 

2.leetcode 54 螺旋矩阵

官方解释:https://leetcode-cn.com/problems/spiral-matrix/solution/luo-xuan-ju-zhen-by-leetcode-solution/

 

3.leetcode 63 不同路径II

动态规划(滚动数组思想):https://leetcode-cn.com/problems/unique-paths-ii/solution/bu-tong-lu-jing-ii-by-leetcode-solution-2/

 

4.leetcode 73 矩阵置零

多种解法:https://leetcode-cn.com/problems/set-matrix-zeroes/solution/ju-zhen-zhi-ling-by-leetcode/

 

5.leetcode 74 搜索二维矩阵

较为巧妙的两种解法:https://leetcode-cn.com/problems/search-a-2d-matrix/solution/sou-suo-er-wei-ju-zhen-by-leetcode/

https://leetcode-cn.com/problems/search-a-2d-matrix/solution/zi-jie-ti-ku-74-zhong-deng-sou-suo-er-wei-ju-zhen-/

 

6.leetcode 75 颜色分类

较为巧妙的解法,一共三种:https://leetcode-cn.com/problems/sort-colors/solution/yan-se-fen-lei-by-leetcode-solution/

 

动态规划

7.leetcode 5 最大回文子串

较为巧妙的三种解法,面试会问到:https://leetcode-cn.com/problems/longest-palindromic-substring/solution/zui-chang-hui-wen-zi-chuan-by-leetcode-solution/

很详细的解释,但是还没看完:https://leetcode-cn.com/problems/longest-palindromic-substring/solution/zhong-xin-kuo-san-dong-tai-gui-hua-by-liweiwei1419/

 

字符串

8.字符串转换函数(atoi)

有限状态机解法:https://leetcode-cn.com/problems/string-to-integer-atoi/

28. 实现 strStr()

字符串匹配问题:kmp、sunday、bm、Horspool算法

43.字符串相乘:

https://leetcode-cn.com/problems/multiply-strings/solution/zi-fu-chuan-xiang-cheng-by-leetcode-solution/

https://leetcode-cn.com/problems/multiply-strings/solution/you-hua-ban-shu-shi-da-bai-994-by-breezean/

76.最小覆盖字符串:

https://leetcode-cn.com/problems/minimum-window-substring/solution/c-unordered_map-8ms-9847-by-karlzhang/

 

剑指offer系列:

offer13 机器人的运动范围:

https://leetcode-cn.com/problems/ji-qi-ren-de-yun-dong-fan-wei-lcof/solution/mian-shi-ti-13-ji-qi-ren-de-yun-dong-fan-wei-dfs-b/

offer62 圆圈中剩下的最后数字

https://leetcode-cn.com/problems/yuan-quan-zhong-zui-hou-sheng-xia-de-shu-zi-lcof/solution/yuan-quan-zhong-zui-hou-sheng-xia-de-shu-zi-by-lee/

offer55 平衡二叉树

https://leetcode-cn.com/problems/ping-heng-er-cha-shu-lcof/solution/mian-shi-ti-55-ii-ping-heng-er-cha-shu-cong-di-zhi/

 

DFS模板

dfs(){

    // 第一步,检查下标是否满足条件

    // 第二步:检查是否被访问过,或者是否满足当前匹配条件

    // 第三步:检查是否满足返回结果条件

    // 第四步:都没有返回,说明应该进行下一步递归
    // 标记
    dfs(下一次)
    // 回溯
}  


main() {
    for (对所有可能情况) {
        dfs()
    }
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值