difference leetcode string 2451

leetcode200 岛屿数量

链接 https://leetcode.cn/problems/number-of-islands/description/ 思路 跟岛屿周长差不多...但我觉得这个比岛屿周长还简单。不知道为什么这个算中等题目,岛屿周长算简单题目 代码 class Solution: def numIslands( ......
岛屿 leetcode 数量 200

Leetcode707. 设计链表

题目描述 你可以选择使用单链表或者双链表,设计并实现自己的链表。 单链表中的节点应该具备两个属性:val 和 next 。val 是当前节点的值,next 是指向下一个节点的指针/引用。 如果是双向链表,则还需要属性 prev 以指示链表中的上一个节点。假设链表中的所有节点下标从 0 开始。 实现 ......
Leetcode 707

leetcode274 H指数 —— 排序后遍历/差分 c++

给你一个整数数组 citations ,其中 citations[i] 表示研究者的第 i 篇论文被引用的次数。计算并返回该研究者的 h 指数。 根据维基百科上 h 指数的定义:h 代表“高引用次数” ,一名科研人员的 h 指数 是指他(她)至少发表了 h 篇论文,并且每篇论文 至少 被引用 h 次 ......
leetcode 指数 274

Educational Codeforces Round 154 (Rated for Div. 2) B. Two Binary Strings

给定两个长度相等的 \(01\) 字符串 \(a\) 和 \(b\) 。每个字符串都是以 \(0\) 开始以 \(1\) 结束。 在一步操作中,你可以选择任意一个字符串: 选择任意两个位置 \(l, r\) 满足 \(s_l = s_r\) ,然后让 \(\forall i \in [l, r], ......
Educational Codeforces Strings Binary Round

Java String类

1.substring() 方法返回字符串的子字符串。 public String substring(int beginIndex) 或 public String substring(int beginIndex, int endIndex) 1 class Main { 2 public st ......
String Java

Leetcode203.移除链表元素

题目描述 给你一个链表的头节点 head 和一个整数 val ,请你删除链表中所有满足 Node.val == val 的节点,并返回 新的头节点。 示例 提交的代码 /** * Definition for singly-linked list. * public class ListNode { ......
Leetcode 元素 203

[Leetcode Weekly Contest]367

链接:LeetCode [Leetcode]2903. 找出满足差值条件的下标 I 给你一个下标从 0 开始、长度为 n 的整数数组 nums ,以及整数 indexDifference 和整数 valueDifference 。 你的任务是从范围 [0, n - 1] 内找出 2 个满足下述所有条 ......
Leetcode Contest Weekly 367

Leetcode 34. Find First and Last Position of Element in Sorted Array

题解 用了两次二分,分别计算第一个>=target的元素位置和第一个>target的元素位置。闭区间二分,[l,r]是未知的,保证每次答案都在[l,r]中,定义清楚nums[l-1]和nums[r+1]和target的关系。因为是while(l < r),所以到l == r时跳出循环,分析l == ......
Leetcode Position Element Sorted Array

数组有没有length()这个方法? String有没有length()这个方法?

数组没有length()这个方法,有length的属性。String有有length()这个方 法。 [1,2,3].lengh 属性 "123".length() 方法 ......
方法 length 数组 String

周赛363 Leetcode 2861. 最大合金数

题解 k个小问题,对每台机器分别计算这台机器最多能制造出多少合金,然后所有机器取max,就是最大合金数。 参数太多不好直接算 如果暴力,枚举制造1份合金,2份合金,... ,但是budget和stock都是1e8,会超时 但是暴力可以给我们一个启发:制造的合金数越多,花的钱越多。我们是否可以猜一个答 ......
Leetcode 2861 363

AT_abc301_h [ABC301Ex] Difference of Distance

AT_abc301_h [ABC301Ex] Difference of Distance 更好的阅读体验 一道基础图论,很好口胡,但是实现不太简单。 考虑离线,把询问挂在边上,按边权从小到大处理。 处理到一个边权时,把边权小于它的边的两端用并查集合并,对于等于这个边权的边在并查集上建图,跑一边 t ......
Difference 301 Distance AT_abc ABC

LeetCode54. 螺旋矩阵Ⅰ

题目描述 给你一个 m 行 n 列的矩阵 matrix ,请按照 顺时针螺旋顺序 ,返回矩阵中的所有元素。 示例 提交的代码 class Solution { public List<Integer> spiralOrder(int[][] matrix) { //行数 int m=matrix.l ......
矩阵 螺旋 LeetCode 54

leetcode45 跳跃游戏2——贪心 (C++/Python)

题目描述: 给定一个长度为 n 的 0 索引整数数组 nums。初始位置为 nums[0]。 每个元素 nums[i] 表示从索引 i 向前跳转的最大长度。换句话说,如果你在 nums[i] 处,你可以跳转到任意 nums[i + j] 处: 0 <= j <= nums[i] i + j < n ......
leetcode Python 45

c: string

/*****************************************************************//** * \file Dustring.c * \brief 字符串操作 * IDE: VSCODE c11 * * * \author geovindu,Geov ......
string

LeetCode59. 螺旋矩阵Ⅱ

题目描述 给你一个正整数 n ,生成一个包含 1 到 n2 所有元素,且元素按顺时针顺序螺旋排列的 n x n 正方形矩阵 matrix 。 示例 提交的代码 class Solution { int matrixLen=0; public int[][] generateMatrix(int n) ......
矩阵 螺旋 LeetCode 59

leetcode2845. 统计趣味子数组的数目

题解 class Solution { public: long long countInterestingSubarrays(vector<int>& nums, int modulo, int k) { int a[100010]; unordered_map<int, int> mp; mp[ ......
数组 数目 趣味 leetcode 2845

LeetCode Day04 24&19&02.07&142

24. 两两交换链表中的节点 这题使用虚拟头结点会更好做,因为有虚拟头结点我们交换结点的时候步骤会更加清晰。 操作此类有指针类型的题目要注意:1.画图避免混乱 2.注意指针先后顺序 class Solution { public ListNode swapPairs(ListNode head) { ......
amp LeetCode 02.07 Day 142

LeetCode209. 长度最小的子数组

题目描述 给定一个含有 n 个正整数的数组和一个正整数 target 。 找出该数组中满足其总和大于等于 target 的长度最小的 连续子数组 [numsl, numsl+1, ..., numsr-1, numsr] ,并返回其长度。如果不存在符合条件的子数组,返回 0 。 示例 输入:targ ......
数组 长度 LeetCode 209

string类构造函数与析构函数

string类构造函数与析构函数 构造函数 构造函数 作用 string s 构造一个空字符串 string s(s1) 生成一个和s1相同的空字符串s string s(s1,5) 将s1[5]以后的部分作为s的初始部分 string s(s1,5,5) 将始于s1[5],长度为5的部分作为s的初 ......
函数 string

[LeetCode] 1354. Construct Target Array With Multiple Sums 多次求和构造目标数组

You are given an array target of n integers. From a starting array arr consisting of n 1's, you may perform the following procedure : let x be the sum ......
数组 Construct LeetCode Multiple 目标

CF1204D2 Kirk and a Binary String (hard version) 题解

CF1204D2 Kirk and a Binary String (hard version) 题解 分析 先来分析 \(01\) 串的最长不下降子序列。全是 \(0\) 显然是不下降的,如果中间出现一个 \(1\),为了维护不下降的性质,后面就只能全是 \(1\)。一句话概括一下,\(0\) 后 ......
题解 version Binary String 1204D

(待完善)Same data type with different length

首先,问题的前提是:不同数据类型的实际大小是依赖于编译器的具体实现的,那么假设在一个long为8B的平台,使用long作为例如memcpy的参数进行数据移动,并且指定的要移动的字节数超过了4B所能表示的最大值,那么如果将此代码移动到一个long为4B的平台,代码就会出现问题,因为此时的long已无法 ......
different length Same data type

LeetCode题库22.括号生成

class Solution: def generateParenthesis(self, n: int) -> List[str]: if n==1: return ['()'] if not n: return None stack,res,l,r=[],[],[],[] for _ in ra ......
括号 题库 LeetCode 22

G. Anya and the Mysterious String

G. Anya and the Mysterious String Anya received a string $s$ of length $n$ brought from Rome. The string $s$ consists of lowercase Latin letters and a ......
Mysterious String Anya and the

string用法合集

\(string\) 用法: 使用索引访问: string s = "123123123"; 则 \(s[0] = 1,s[1] = 2 \cdots\) 。 可以直接用运算符比较: string s1 = "asd"; string s2 = "dsa"; return s1 < s2; //按字 ......
string

C. Decreasing String

C. Decreasing String Recall that string $a$ is lexicographically smaller than string $b$ if $a$ is a prefix of $b$ (and $a \ne b$), or there exists an ......
Decreasing String

LeetCode977. 有序数组的平方

题目描述 给你一个按 非递减顺序 排序的整数数组 nums,返回 每个数字的平方 组成的新数组,要求也按 非递减顺序 排序。 示例1 输入:nums = [-4,-1,0,3,10] 输出:[0,1,9,16,100] 解释:平方后,数组变为 [16,1,0,9,100] 排序后,数组变为 [0,1 ......
数组 LeetCode 977

Element type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got undefined

原因就是组件引入错误,应该是 import {BillReverse} form '../xx' 写成了 import Reverse from '../xx' 两个错误 1. 没写大括号 2. 组件名错误 如何从打包后的文件分析导出内容格式,待解决 ......
components composite for undefined expected

CF1886C Decreasing String 题解

题面 \(S_n\) 由 \(S_{n-1}\) 去掉一个字母得到,\(S=S_1+S_2+...+S_n\) 给定 \(S_1\) 求 \(S\) 的第 \(N\) 位 solution 我们先考虑怎样去字母能保持字典序最小 显然,我们发现如果一个字母比前面那个字母小,那么我们就要删除前面那个字母 ......
题解 Decreasing String 1886C 1886

@NotBlank注解String字段会报错

一、背景 项目场景: 这里说下@NotEmpty、@NotBlank、@NotNull 的区别: 它们所在的包:javax.validation.constraints.NotEmpty、javax.validation.constraints.NotBlank 、javax.validation. ......
注解 字段 NotBlank String