字符串 字符leetcode reverse

C字符串函数(一)

# C字符串函数(一) > - `strlen()` -> 统计字符串长度 > - `strcat()`和`strncat()`函数 -> 拼接字符串函数 > - `strcmp()`和`strncmp()`函数 -> 字符串比较函数 > - `strcpy()`和`strncpy()`函数 -> ......
字符串 函数 字符

[LeetCode] 1347. Minimum Number of Steps to Make Two Strings Anagram 制造字母异位词的最小步骤数

You are given two strings of the same length `s` and `t`. In one step you can choose **any character** of `t` and replace it with **another character* ......
字母 LeetCode 步骤 Anagram Minimum

leetcode-图论总结

此文总结一下常见图论算法,代码可以为后续遇见类似题目提供参考: 1. 图的表示: 邻接矩阵:可通过创建数组得到 邻接表:我个人喜欢通过LinkedList<int[]>[] graph = new LinkedList[n];得到。 Edge List:同样可以通过LinkedList<int[]> ......
leetcode

int类型在接收null会报错,需要使用Java包装类型Integer,且Integer不能equal String字符串

int类型在接收null会报错,需要使用Java包装类型Integer,且Integer不能equal String字符串 package com.example.core.mydemo.json2; /** * int类型在接收null会报错,需要使用Java包装类型Integer */ publ ......
Integer 类型 字符串 字符 String

Json解析字符串报错syntax error, expect {, actual string, pos 0, fastjson-version 1.2.62解决

Expected BEGIN_OBJECT but was STRING at line 1 column 2 path $ syntax error, expect {, actual string, pos 0, fastjson-version 1.2.62 syntax error, exp ......

字符串轮转

字符串轮转。给定两个字符串s1和s2,请编写代码检查s2是否为s1旋转而成(比如,waterbottle是erbottlewat旋转后的字符串)。 示例1: 输入:s1 = "waterbottle", s2 = "erbottlewat" 输出:True 示例2: 输入:s1 = "aa", s2 ......
字符串 字符

Java开发手册中为什么不建议在for循环中使用"+"进行字符串操作

场景 java开发手册中对于循环体中进行字符串的拼接要求如下: 【推荐】循环体内,字符串的连接方式,使用 StringBuilder 的 append 方法进行扩展。 说明:下例中,反编译出的字节码文件显示每次循环都会 new 出一个 StringBuilder 对象,然后进行 append操作, ......
quot 字符串 字符 手册 建议

算法——字符串(一)

1、两数相加 1 class Solution { 2 public ListNode addTwoNumbers(ListNode l1, ListNode l2) { 3 ListNode pre = new ListNode(); 4 ListNode cur = pre; 5 int car ......
字符串 算法 字符

获取字符串个数和长度

SAP 中strlen()只能计算字符串的个数,不能计算含有中文字符串的长度。 FIELD-SYMBOLS:<FV> TYPE STRING. DATA:LV_SRT TYPE I. DATA:LV TYPE REF TO DATA. DATA:LV_SSSS TYPE CHAR255 . LV_S ......
字符串 长度 字符 个数

字符串输出的两种调用方法

class ReprStr: def __repr__(self): # 命令行交互环境,输入对象名 回车,调用此方法。 字符串真正的样子 return "返回的是 __repr__ 方法" def __str__(self): # 用 print 输出变量时,调用此方法。 经过Python优化,更 ......
字符串 字符 方法

shell中的#%*处理字符用法【转】

shell提供了简单强大字符串处理方式,有时候需要对path进行处理,通过#%*的搭配使用,可以方便快捷的得到结果。废话少说,举例子。 #!/usr/bin/env bash DIR="/dir1/dir2/dir3/abc.def.txt" echo "DIR: $DIR" #删除最左边/及其左边 ......
字符 shell

leetcode-滑动窗口总结

滑动窗口是我在刷题时感觉比较困难的部分,简单做一个总结,防止之后又忘了: 一般模板如下: // 注意:java 代码由 chatGPT🤖 根据我的 cpp 代码翻译,旨在帮助不同背景的读者理解算法逻辑。 // 本代码还未经过力扣测试,仅供参考,如有疑惑,可以参照我写的 cpp 代码对比查看。 /* ......
leetcode

Leetcode 2460. 对数组执行操作

### 题目: 给你一个下标从 **0** 开始的数组 `nums` ,数组大小为 `n` ,且由 **非负** 整数组成。 你需要对数组执行 `n - 1` 步操作,其中第 `i` 步操作(从 **0** 开始计数)要求对 `nums` 中第 `i` 个元素执行下述指令: - 如果 `nums[i ......
数组 Leetcode 2460

linux 中输出指定字符连续重复的行

001、 [root@PC1 test3]# ls a.txt [root@PC1 test3]# cat a.txt ## 测试数据 334 gene kkk yyy gene gene kkk gene gene mmmm [root@PC1 test3]# awk 'BEGIN{a="no"} ......
字符 linux

linux 中删除文本开头至匹配字符之间的内容

001、 [root@PC1 test3]# ls a.txt [root@PC1 test3]# cat a.txt ## 测试数据 3 5 44 agf gene 45 87 gene dfg iu gene 887 777 [root@PC1 test3]# sed '1,/gene/{/ge ......
开头 字符 文本 之间 内容

[LeetCode] 2460. Apply Operations to an Array

You are given a 0-indexed array nums of size n consisting of non-negative integers. You need to apply n - 1 operations to this array where, in the ith ......
Operations LeetCode Apply Array 2460

LeetCode 669. 修剪二叉搜索树

#### 思路 - 遍历所有节点,如果当前节点不在所给区间里,删除该点;否则 - 如果该点要被删除,将其左右子树其中之一提上来即可 - 根节点位于左右子树取值区间的中间,如果该点要被删除,那么一定存在不满足要求的子树,不可能两棵子树同时保留 #### 代码 ```c class Solution { ......
LeetCode 669

[LeetCode] 1346. Check If N and Its Double Exist 检查整数及其两倍数是否存在

Given an array `arr` of integers, check if there exist two indices `i` and `j` such that : - `i != j` - `0 这道题给了一个整型数组,让检测是否有一个数字和其倍数同时存在的情况。一看到这道题博主就 ......
倍数 整数 LeetCode Double Check

LeetCode 周赛 348(2023/06/05)数位 DP 模板学会了吗

> **本文已收录到 [AndroidFamily](https://github.com/pengxurui/AndroidFamily),技术和职场问题,请关注公众号 [彭旭锐] 加入知识星球提问!** - 往期回顾:[LeetCode 单周赛第 347 场 · 二维空间上的 LIS 最长递增子 ......
数位 LeetCode 模板 2023 348

Leetcode 2517. 礼盒的最大甜蜜度

### 题目: 给你一个正整数数组 `price` ,其中 `price[i]` 表示第 `i` 类糖果的价格,另给你一个正整数 `k` 。 商店组合 `k` 类 不同 糖果打包成礼盒出售。礼盒的 **甜蜜度** 是礼盒中任意两种糖果 **价格** 绝对差的最小值。 返回礼盒的 **最大** 甜蜜度 ......
礼盒 Leetcode 2517

Leetcode 1156. 单字符重复子串的最大长度

### 题目: 如果字符串中的所有字符都相同,那么这个字符串是单字符重复的字符串。 给你一个字符串 `text`,你只能交换其中两个字符一次或者什么都不做,然后得到一些单字符重复的子串。返回其中最长的子串的长度。 ### 难度:中等 #### 示例1: ``` 输入:text = "ababa" 输 ......
单字 长度 Leetcode 1156

LeetCode 450. 删除二叉搜索树中的节点

```c class Solution { public: TreeNode* deleteNode(TreeNode* root, int key) { del(root,key); return root; } void del(TreeNode* &root,int key) { if(!ro ......
节点 LeetCode 450

LeetCode 538. 把二叉搜索树转换为累加树

```c class Solution { public: void dfs(TreeNode* root,int &sum)//从大到小遍历所有节点 { if(!root) return; dfs(root->right,sum); sum+=root->val; root->val=sum; d ......
LeetCode 538

[LeetCode] 1345. Jump Game IV 跳跃游戏之四

Given an array of integers `arr`, you are initially positioned at the first index of the array. In one step you can jump from index `i` to index: - `i ......
LeetCode 1345 Jump Game IV

linux 中实现输出匹配字符之后或之前的若干行

001、输出匹配字符之后的若干行 [root@PC1 test4]# ls a.txt [root@PC1 test4]# cat a.txt ## 测试数据 01 02 kk 03 04 05 06 07 kk 08 09 10 11 12 ## 输出匹配字符之后的3行 [root@PC1 tes ......
字符 linux

将10进制数转换为16进制的字符

>将十进制数转换为十六进制数,dec2hexa:将十进制数转换为十六进制数 ```c #include void dec2hexa(int n) { int i=0,d=n; int m=0,t=0; char hexa[64]; char *hmap="0123456789ABCDEF"; whi ......
进制 字符

LeetCode 501. 二叉搜索树中的众数

``` class Solution { public: vector res; int cnt=0; int find(TreeNode* root,int val)//返回当前子树值为val的个数 { if(!root) return 0; return find(root->left,val) ......
LeetCode 501