随笔分类 - leetcode
摘要:/* * @lc app=leetcode.cn id=226 lang=cpp * * [226] 翻转二叉树 * * https://leetcode-cn.com/problems/invert-binary-tree/description/ * * algorithms * Easy (7
阅读全文
摘要:刷链表题目(训练递归思维) 递归反转链表的一部分 Leetcode [92][206]. 反转链表ii&i-输入一个链表,反转链表后,输出链表的所有元素。 如何k个一组反转链表 Leetcode 25. K 个一组反转链表 如何判断回文链表 Leetcode [234] 回文链表 回文 链表 二叉树
阅读全文
摘要:基本技巧 动态规划解题套路框架 基础代码框架介绍 动态规划答疑篇 最优子结构 状态压缩:对动态规划进行降维打击 动态规划和回溯算法到底谁是谁爹? 子序列类型问题 经典动态规划:编辑距离 Leetcode 72 编辑距离edit-distance-动态规划,计算两词之间变换的最小步数 信封嵌套问题 L
阅读全文
摘要:/* * @lc app=leetcode.cn id=1312 lang=cpp * * [1312] 让字符串成为回文串的最少插入次数 * * https://leetcode-cn.com/problems/minimum-insertion-steps-to-make-a-string-pa
阅读全文
摘要:/* * @lc app=leetcode.cn id=234 lang=cpp * * [234] 回文链表 * * https://leetcode-cn.com/problems/palindrome-linked-list/description/ * * algorithms * Easy
阅读全文
摘要:/* * @lc app=leetcode.cn id=99 lang=cpp * * [99] 恢复二叉搜索树 * * https://leetcode-cn.com/problems/recover-binary-search-tree/description/ * * algorithms *
阅读全文
摘要:/* * @lc app=leetcode.cn id=198 lang=cpp * * [198] 打家劫舍 * * https://leetcode-cn.com/problems/house-robber/description/ * * algorithms * Medium (49.14%
阅读全文
摘要:这些题目具有共性,iv是最泛化的题目,所有其他题目都是iv的简化 二、思路: labuladong 这个问题的「状态」有三个,第一个是天数,第二个是当天允许交易的最大次数,第三个是当前的持有状态(即之前说的 rest 的状态,我们不妨用 1 表示持有,0 表示没有持有)。 我们用一个三维数组 dp
阅读全文
摘要:/* * @lc app=leetcode.cn id=650 lang=cpp * * [650] 只有两个键的键盘 * * https://leetcode-cn.com/problems/2-keys-keyboard/description/ * * algorithms * Medium
阅读全文
摘要:877. 石子游戏 题目: Alice 和 Bob 用几堆石子在做游戏。一共有偶数堆石子,排成一行;每堆都有 正 整数颗石子,数目为 piles[i] 。 游戏以谁手中的石子最多来决出胜负。石子的 总数 是 奇数 ,所以没有平局。 Alice 和 Bob 轮流进行,Alice 先开始 。 每回合,玩
阅读全文
摘要:/* * @lc app=leetcode.cn id=312 lang=cpp * * [312] 戳气球 * * https://leetcode-cn.com/problems/burst-balloons/description/ * * algorithms * Hard (67.72%)
阅读全文
摘要:题目是这样:你面前有一栋从 1 到N共N层的楼,然后给你K个鸡蛋(K至少为 1)。现在确定这栋楼存在楼层0 <= F <= N,在这层楼将鸡蛋扔下去,鸡蛋恰好没摔碎(高于F的楼层都会碎,低于F的楼层都不会碎)。现在问你,最坏情况下,你至少要扔几次鸡蛋,才能确定这个楼层F呢? PS:F 可以为 0,比
阅读全文
摘要:基础贪心问题:labuladong 给你很多形如[start,end]的闭区间,请你设计一个算法,算出这些区间中最多有几个互不相交的区间。 举个例子,intvs=[[1,3],[2,4],[3,6]],这些区间最多有两个区间互不相交,即[[1,3],[3,6]],你的算法应该返回 2。注意边界相同并
阅读全文
摘要:322: /* * @lc app=leetcode.cn id=322 lang=cpp * * [322] 零钱兑换 * * https://leetcode-cn.com/problems/coin-change/description/ * * algorithms * Medium (43
阅读全文
摘要:/* * @lc app=leetcode.cn id=416 lang=cpp * * [416] 分割等和子集 * * https://leetcode-cn.com/problems/partition-equal-subset-sum/description/ * * algorithms
阅读全文
摘要:/* * @lc app=leetcode.cn id=516 lang=cpp * * [516] 最长回文子序列 * * https://leetcode-cn.com/problems/longest-palindromic-subsequence/description/ * * algor
阅读全文
摘要:/* * @lc app=leetcode.cn id=5 lang=cpp * * [5] 最长回文子串 * * https://leetcode-cn.com/problems/longest-palindromic-substring/description/ * * algorithms *
阅读全文
摘要:/* * @lc app=leetcode.cn id=712 lang=cpp * * [712] 两个字符串的最小ASCII删除和 * * https://leetcode-cn.com/problems/minimum-ascii-delete-sum-for-two-strings/desc
阅读全文
摘要:/* * @lc app=leetcode.cn id=583 lang=cpp * * [583] 两个字符串的删除操作 * * https://leetcode-cn.com/problems/delete-operation-for-two-strings/description/ * * a
阅读全文
摘要:/* * @lc app=leetcode.cn id=354 lang=cpp * * [354] 俄罗斯套娃信封问题 * * https://leetcode-cn.com/problems/russian-doll-envelopes/description/ * * algorithms *
阅读全文