substring leetcode maximum length

【DP】LeetCode 剑指 Offer 60. n个骰子的点数

题目链接 剑指 Offer 60. n个骰子的点数 思路 动态规划问题中,只用考虑第 n 个阶段如何由第 n-1 个阶段转化过来 在本题中,就是投掷 n 个骰子的结果如何由 投掷 n-1 个骰子的结果转化过来。 代码 class Solution { public double[] dicesPro ......
骰子 点数 LeetCode Offer 60

leetcode-1089-easy

Duplicate Zeros Given a fixed-length integer array arr, duplicate each occurrence of zero, shifting the remaining elements to the right. Note that ele ......
leetcode 1089 easy

leetcode-1009-easy

Complement of Base 10 Integer The complement of an integer is the integer you get when you flip all the 0's to 1's and all the 1's to 0's in its binar ......
leetcode 1009 easy

leetcode-1317-easy

Convert Integer to the Sum of Two No-Zero Integers No-Zero integer is a positive integer that does not contain any 0 in its decimal representation. Gi ......
leetcode 1317 easy

【LeetCode】35.搜索插入位置

题目描述 解法 思路:二分查找 class Solution { public: int searchInsert(vector<int>& nums, int target) { int left = 0, right = nums.size() - 1; int count = 0; if(nu ......
LeetCode 位置 35

【LeetCode】278.第一个错误的版本

题目描述 解法 思路:二分查找 注意:当第一个 isBadVersion(mid)的结果为true时,得到第一个错误的版本 // The API isBadVersion is defined for you. // bool isBadVersion(int version); class Sol ......
LeetCode 错误 版本 278

【LeetCode】704.二分查找

题目描述 解法 class Solution { public: int search(vector<int>& nums, int target) { int left = 0; int right = nums.size()-1; while(left <= right){ int mid = ......
LeetCode 704

JavaScript系列 -> 截取字符串方法 substring/slice/substr

因为对于截取字符串的方法时常弄混,每次使用的时候,都需要不断的看教程回顾,现在总结到这里: substring substring(start,end): start/end 分别为开始位置和结束位置; 左闭右开,不包含结束位置; start/end 应该为非负整数; start小于0,当成0处理; ......
字符串 JavaScript substring 字符 方法

leetcode 176

leetcode 176 第二高的薪水,查第二高的人的信息 1、使用ifnull(exp1, exp2)函数,limit offset子句 select ifnull( (select distinct salary from Employee order by salary desc limit ......
leetcode 176

代码随想录Day14-Leetcode144. 二叉树的前序遍历,94.二叉树的中序遍历,145.二叉树的后序遍历

递归遍历 前序遍历:根左右 一路俯冲,然后回头 /** * Definition for a binary tree node. * function TreeNode(val, left, right) { * this.val = (val undefined ? 0 : val) * this ......
随想录 随想 Leetcode 代码 Day

LeetCode 1641 统计字典序元音字符串的数目

给你一个整数 n,请返回长度为 n 、仅由元音 (a, e, i, o, u) 组成且按 字典序排列 的字符串数量。 字符串 s 按 字典序排列 需要满足:对于所有有效的 i,s[i] 在字母表中的位置总是与 s[i + 1] 相同或在 s[i + 1] 之前。 示例 1: 输入:n = 1 输出: ......
元音 字符串 数目 字典 字符

【DFS】LeetCode 110. 平衡二叉树

题目链接 110. 平衡二叉树 思路 一个空树肯定是平衡二叉树,并且一个平衡二叉树的子树也是平衡二叉树。利用这两条性质我们可以推断出代码中含有 root == null -> return true 和 isBalanced(root.left) && isBalanced(root.right)。 ......
LeetCode DFS 110

Leetcode81. 搜索旋转排序数组 II

class Solution { public: bool check(vector<int> &nums,int target,int l,int r)//[l,r]区间查找target { while(l<r) { int mid=(l+r+1)>>1; if(target>=nums[mid] ......
数组 Leetcode 81 II

【单调队列】LeetCode 面试题59 - II. 队列的最大值

题目链接 面试题59 - II. 队列的最大值 思路 可以看参考题解:如何解决 O(1) 复杂度的 API 设计题 一开始想到使用单变量 max 来存储最大值,但是会产生两点问题: 当 max 弹出队列之后,下一个最大值是多少没法知道 如果有多个 max,那么当一个最大值弹出队列之后,队列中还有没有 ......
队列 最大值 LeetCode II

【单调队列】LeetCode 239. 滑动窗口最大值

题目链接 239. 滑动窗口最大值 思路 单调队列的使用方法,将滑动窗口 代码 class Solution { public int[] maxSlidingWindow(int[] nums, int k) { int[] result = new int[nums.length - k + 1 ......
最大值 队列 LeetCode 239

LeetCode 1092 最短公共超序列

LeetCode | 1092.最短公共超序列 给出两个字符串 str1 和 str2,返回同时以 str1 和 str2 作为子序列的最短字符串。如果答案不止一个,则可以返回满足条件的任意一个答案。 (如果从字符串 T 中删除一些字符(也可能不删除,并且选出的这些字符可以位于 T 中的 任意位置) ......
序列 LeetCode 1092

链表操作-leetcode 92 -反转链表2

题目描述: 给你单链表的头指针 head 和两个整数 left 和 right ,其中 left <= right 。请你反转从位置 left 到位置 right 的链表节点,返回 反转后的链表 。 示例: 输入:head = [1,2,3,4,5], left = 2, right = 4 输出: ......
leetcode 92

[LeetCode] 2068. Check Whether Two Strings are Almost Equivalent

Two strings word1 and word2 are considered almost equivalent if the differences between the frequencies of each letter from 'a' to 'z' between word1 a ......
Equivalent LeetCode Whether Strings Almost

mysql加解密,substring substring_index函数

mysql加解密,substring substring_index函数 SELECT to_base64(AES_ENCRYPT('测试串','key12345678')) ;SELECT AES_DECRYPT(from_base64('iqJIDwYLlcAZ/AP3VvODJg=='),'k ......
substring substring_index 函数 mysql index

Leetcode(剑指offer专项训练)——DP专项(3)

分割等和子集 给定一个非空的正整数数组 nums ,请判断能否将这些数字分成元素和相等的两部分。 Link 错误思路 TLS的思路: 记录下所有子集在mp中,但是会造成超时 class Solution { public: bool canPartition(vector<int>& nums) { ......
专项 Leetcode offer

【LeetCode滑动窗口专题】水果成篮 + 最小覆盖子串(hard)

二刷刷到滑动窗口,发现有一些细节和遗漏,在此补充 实际上关于滑动窗口的题还有一题:最小长度的子数组 进入正题 水果成篮 LeetCode904水果成篮 你正在探访一家农场,农场从左到右种植了一排果树。这些树用一个整数数组 fruits 表示,其中 fruits[i] 是第 i 棵树上的水果 种类 。 ......
盖子 LeetCode 水果 专题 hard

Leetcode 23. 合并 K 个升序链表(分治)

题目链接在这里:合并K个升序链表 对于多个升序链表的合并,如果用C++写的话可以使用优先队列,队列里面存放的都是每一个链表的头结点。 也可以使用分治的方法来做,每次将链表两两合并,这样节约了时间。 这道题巩固了python中递归的应用。 # Definition for singly-linked ......
升序 Leetcode 23

【DP】LeetCode 121. 买卖股票的最佳时机

题目链接 121. 买卖股票的最佳时机 思路 状态转移方程为 $dp[i] = max(0, dp[i - 1], prices[i] - min)$,设置 dp[0] = 0,所以在取最大值的过程中可以省略0,只需要写 dp[i] = Math.max(dp[i - 1], prices[i] - ......
时机 LeetCode 股票 121

LeetCode 1638 统计只差一个字符的子串数目

LeetCode | 1638.统计只差一个字符的子串数目 给你两个字符串 s 和 t ,请你找出 s 中的非空子串的数目,这些子串满足替换 一个不同字符 以后,是 t 串的子串。换言之,请你找到 s 和 t 串中 恰好 只有一个字符不同的子字符串对的数目。 比方说, "computer" and  ......
数目 字符 LeetCode 1638

「题解」ABC290F Maximum Diameter

没动脑子就 gf 一路写下来了......实际上就是把插板法的 gf 写了一下/zk 首先考虑一下一个 $X$ 合法是什么情况,那就是总和是 $2n-2$ 并且保证 $0<X_i<n$。 证明就考虑贪心构造一下,每个 $1$ 挂在一个 $\geq 2$ 的上面,不断挂使得最后只剩下两个 $1$ 和一 ......
题解 Diameter Maximum 290F ABC

LeetCode 周赛 338,贪心 / 埃氏筛 / 欧氏线性筛 / 前缀和 / 二分查找 / 拓扑排序

本文已收录到 AndroidFamily,技术和职场问题,请关注公众号 [彭旭锐] 提问。 大家好,我是小彭。 上周末是 LeetCode 第 338 场周赛,你参加了吗?这场周赛覆盖的知识点很多,第四题称得上是近期几场周赛的天花板。 小彭的技术交流群 02 群来了,公众号回复 “加群” 加入我们~ ......
拓扑 前缀 线性 LeetCode 338

代码随想录Day11-Leetcode20. 有效的括号,1047. 删除字符串中的所有相邻重复项,150. 逆波兰表达式求值

20. 有效的括号 写过很多遍了,但还是不能秒a /** * @param {string} s * @return {boolean} */ var isValid = function(s) { let stack = [] let obj = {'(':')', '[':']', '{':'} ......
随想录 括号 表达式 字符串 随想

代码随想录Day13-Leetcode239. 滑动窗口最大值,347.前 K 个高频元素,栈和队列总结

239. 滑动窗口最大值 一开始没有思路,暴力了,然后果然超时; 看提示中的单调队列没有特别明白;后面反应过来跟单调栈很像; 也确实很符合本题的情况,一旦队尾出现更大的数,前面更小的数就不需要了, 他们不会成为最大数被弹出后的备选。 值得注意的是本题数次出现区间错误,一开始我的操作居然是删除q[l] ......
随想录 最大值 队列 随想 Leetcode

LeetCode459. 重复的子字符串

题目描述: 给定一个非空的字符串 s ,检查是否可以通过由它的一个子串重复多次构成。 示例 1: 输入: s = "abab" 输出: true 解释: 可由子串 "ab" 重复两次构成。 示例 2: 输入: s = "aba" 输出: false 示例 3: 输入: s = "abcabcabca ......
字符串 字符 LeetCode 459

[LeetCode] 1337. The K Weakest Rows in a Matrix 矩阵中战斗力最弱的 K 行

You are given an m x n binary matrix mat of 1's (representing soldiers) and 0's (representing civilians). The soldiers are positioned in front of the ......
矩阵 战斗力 LeetCode Weakest Matrix