difference leetcode string 2451

LeetCode27. 移除元素

描述 给你一个数组 nums 和一个值 val,你需要 原地 移除所有数值等于 val 的元素,并返回移除后数组的新长度。 不要使用额外的数组空间,你必须仅使用 O(1) 额外空间并 原地 修改输入数组。 元素的顺序可以改变。你不需要考虑数组中超出新长度后面的元素。 示例1 输入:nums = [3 ......
LeetCode 元素 27

算法训练day30 LeetCode93.78.90

算法训练day30 LeetCode93.78.90 93.复原IP地址 题目 93. 复原 IP 地址 - 力扣(LeetCode) 题解 代码随想录 (programmercarl.com) 使用'.'切割字符串、结束条件为字符串中有三个'.'、同时要确定字符串符合的条件 长度为不为1时,首字符 ......
算法 LeetCode day 30 93

LeetCode704. 二分查找

描述 给定一个 n 个元素有序的(升序)整型数组 nums 和一个目标值 target ,写一个函数搜索 nums 中的 target,如果目标值存在返回下标,否则返回 -1。 示例1 输入: nums = [-1,0,3,5,9,12], target = 9 输出: 4 解释: 9 出现在 nu ......
LeetCode 704

LeetCode Day02 977&209&59

第一题是[977. 有序数组的平方]这题解题思路依旧可以用双指针,指针分别指向数组的头尾两端,然后对两端求乘积比较大小,把乘积值更大的存储到数组尾端,然后指针更新位置,代码如下。 public int[] sortedSquares(int[] nums) { //res用于存储平方和结果 int[ ......
amp LeetCode Day 977 209

【OPCUA】UA_String转为QString

字符串:UA_String typedef struct { size_t length; UA_Byte* data; }UA_String; 生成UA_String的API有三个UA_STRING,UA_STRING_ALLOC,UA_STRING_STATIC UA_STRING - 包装现有 ......
UA_String QString String OPCUA UA

LeetCode Day01 704. & 27.

###### [704. Binary Search](https://leetcode.cn/problems/binary-search/)入门必备二分查找了。必须是在一堆**有序的**数组中找到其中特定某个val值。###### 二分算法的思路:*首先取一个基准值,这个值我们一般取数组的中间位 ......
LeetCode Day 704 amp 01

【LeetCode递归】括号生成,使用dfs

括号匹配 数字 n 代表生成括号的对数,请你设计一个函数,用于能够生成所有可能的并且 有效的 括号组合。 示例 1: 输入:n = 3 输出:["((()))","(()())","(())()","()(())","()()()"] 示例 2: 输入:n = 1 输出:["()"] 提示: 1 < ......
括号 LeetCode dfs

C++ 11 String 类

String 类 介绍 手写一个 String 类 内容 一个 String 类 默认构造函数 带指针的构造函数 拷贝构造函数 移动构造函数 复制构造函数 析构函数 重载操作符 = += == [] << >> 字符串长度 字符指针 字符串操作函数 字符串拷贝 strcpy 获取字符串长度 strl ......
String 11

[LeetCode] 2863. Maximum Length of Semi-Decreasing Subarrays_Medium tag: stack

You are given an integer array nums. Return the length of the longest semi-decreasing subarray of nums, and 0 if there are no such subarrays. A subarr ......

[LeetCode] 2434. Using a Robot to Print the Lexicographically Smallest String_Medium tag: stack

You are given a string s and a robot that currently holds an empty string t. Apply one of the following operations until s and t are both empty: Remov ......

Python word'str'(字符串前缀string prefix)的种类

Python 字符串前缀(String prefix) r 'string' r' ',用法是不会对后方字符串中的转义符进行转义,如: str = r'\n' print(str) # 会直接输出\n,并不会输出换行 f 'string' f ' ',用法是对字符进行格式化就和str.format( ......
前缀 字符串 字符 种类 Python

CF1707B [Difference Array]

Problem 题目简述 设序列 \(a\) ,并且是单调递增的。设 \(a\) 当前长度为 \(l\),你要对 \(a\) 作差分,即令 \(b_i = a_{i+1} - a_i(1\le i < l)\),然后使 \(b\) 数组保持单调递增。 一直持续操作,直到 \(a\) 数组中只有一个元 ......
Difference 1707B Array 1707 CF

Educational Codeforces Round 105 (Rated for Div. 2) A. ABC String

给一个长为 \(n\) 的字符串 \(a\) ,\(n\) 是偶数,字符串中只包含三种字符 \(A, B, C\) 。规定一个合法的字符串为一个符合入栈规则的字符串。 需要构造一个长为 \(n\) 的括号字符串 \(b\) 。 \(b\) 是一个合法的括号序列 \(\forall 1 \leq i ......
Educational Codeforces String Round Rated

[ARC128E] K Different Values

[ARC128E] K Different Values 考察 \(k=2\) 的情形,这个很经典,就是绝对众数。这样的话我们发现显然的一个必要条件是 \(\max A_i \le \lceil \frac{n}{k} \rceil\)。进一步,我们按照 \(k\) 为块长分块,还需满足 \(A_i ......
Different Values 128E ARC 128

2023.10.10 js.Array和js.String

1 定义数组 2 1.var arr = new Array{1,2,3,4...}; 3 2.var arr = [1,2,3,4]; 4 访问 5 arr[索引] = 值 6 7 同一数组的类型可变,长度可变。 8 9 Array中的属性和方法 10 arr.length//获取数组长度 11 ......
String Array 2023 10 js

LeetCode101.对称二叉树

class Solution { //ArrayDeque不支持添加null public boolean isSymmetric(TreeNode root) { return dfs(root.left,root.right); } // 实际上,递归比较的就是根节点左右子树上,对称位置的节点 ......
LeetCode 101

算法解析:LeetCode——机器人碰撞和最低票价

摘要:本文由葡萄城技术团队原创。转载请注明出处:葡萄城官网,葡萄城为开发者提供专业的开发工具、解决方案和服务,赋能开发者。 机器人碰撞 问题: 现有 n 个机器人,编号从 1 开始,每个机器人包含在路线上的位置、健康度和移动方向。 给你下标从 0 开始的两个整数数组 positions、health ......
票价 机器人 算法 LeetCode 机器

C++之字符串string

记录cpp相关的字符串操作 #include <string> 以下是string相关的常见操作 反转 字符串相加 转为int型:利用stoi将字符串转为整型(https://www.geeksforgeeks.org/stdstoi-function-in-cpp/) 同float C++ 字符串 ......
字符串 字符 string

[LeetCode] 2282. Number of People That Can Be Seen in a Grid_Medium tag: stack.

You are given an m x n 0-indexed 2D array of positive integers heights where heights[i][j] is the height of the person standing at position (i, j). A ......
Grid_Medium LeetCode Number Medium People

Data structure - Stack 小结及leetcode相关题目

Linear data structure - Stack O(1) for push O(1) for pop O(1) for top - Basic skills 先进后出 [LeetCode] 232. Implement Queue using Stacks_Easy tag: stack ......
小结 structure leetcode 题目 Stack

[LeetCode] 1944. Number of Visible People in a Queue_Hard tag: stack

There are n people standing in a queue, and they numbered from 0 to n - 1 in left to right order. You are given an array heights of distinct integers ......
Queue_Hard LeetCode Visible Number People

【论文笔记】A theory of learning from different domains

防盗 https://www.cnblogs.com/setdong/p/17756127.html domain adaptation 领域理论方向的重要论文. 这篇笔记主要是推导文章中的定理, 还有分析定理的直观解释. 笔记中的章节号与论文中的保持一致. 1. Introduction doma ......
different learning domains 笔记 theory

leetcode122买卖股票的最佳时机——贪心、动态规划

题目描述: 给你一个整数数组 prices ,其中 prices[i] 表示某支股票第 i 天的价格。 在每一天,你可以决定是否购买和/或出售股票。你在任何时候 最多 只能持有 一股 股票。你也可以先购买,然后在 同一天 出售。 返回 你能获得的 最大 利润 。 示例 1: 输入:prices = ......
时机 leetcode 股票 动态 122

LeetCode 383 赎金信

LeetCode 383 赎金信 1. 题目地址 https://leetcode.cn/problems/ransom-note/?envType=study-plan-v2&envId=top-interview-150 2. 题解 这道题是一道哈希表的经典例题,具体步骤如下: 1. 定义哈希表 ......
LeetCode 383

LeetCode 392 判断子序列

LeetCode 392 判断子序列 1. 题目地址 https://leetcode.cn/problems/is-subsequence/?envType=study-plan-v2&envId=top-interview-150 2. 题解 采用双指针算法,具体步骤如下: 1. i指针指向s的 ......
序列 LeetCode 392

CF1886C Decreasing String

单调栈的应用。 显然可以 \(O(n)\) 地找到 \(pos\) 所属的 \(s_i\) 段,所以我们只需要得到 \(s_i\) 即可。不难发现,删除元素的规则应该是从 \(1\) 到 \(n\) 枚举每个元素,删除它前面“紧邻的”比他大的元素(例如对于 eadcb 中的 b 删除掉 dc)。 赛 ......
Decreasing String 1886C 1886 CF

java:String的getBytes()方法

1、String.getBytes方法:获取该编码格式的字符 在Java中,String的getBytes()方法是得到一个操作系统默认的编码格式的字节数组。这个表示在不同的OS下,返回的东西不一样。 String.getBytes(String decode)方法会根据指定的decode编码返回某 ......
getBytes 方法 String java

顺序容器(vector、deque、list、forward_list、array 、string)

一、顺序容器概述 顺序容器提供了控制元素存储和访问顺序的能力,顺序与元素加入容器时的位置相对应。1、常见的顺序容器类型:vector:可变大小的数组。支持快速随机访问,在尾部之外的位置插入或者删除元素可能很慢。deque:双端队列。支持快速随机访问。在头尾位置插入/删除速度很快。只支持双向顺序访问。 ......
list forward_list 容器 顺序 forward

ARC166E Fizz Buzz Difference

题面传送门 首先一个观察是随着 \(n\) 的增大,最长的区间肯定是增大的,因此可以直接把等式放缩成 \(\leq n\)。 另一个观察使为了使区间长度最大,左右端点肯定是顶着两个 \(a\) 的,不妨设其为 \(al+1\) 和 \(ar-1\)。 将 \(a,b\) 先搞成互质的,那么现在的问题 ......
Difference 166E Fizz Buzz ARC

leetcode189旋转数组解决——局部旋转 (C/C++/python)

给定一个整数数组 nums,将数组中的元素向右轮转 k 个位置,其中 k 是非负数。 示例 1: 输入: nums = [1,2,3,4,5,6,7], k = 3 输出: [5,6,7,1,2,3,4] 解释: 向右轮转 1 步: [7,1,2,3,4,5,6] 向右轮转 2 步: [6,7,1, ......
数组 局部 leetcode python 189