字符串 字符 单词leetcode

练习——字符反转

package com.someexercise; import java.util.Arrays; public class restring { /* 字符反转 将字符串中指定部分进行反转。比如将"abcdef"反转为"aedcbf" 编写方法 public static String reve ......
字符

Leetcode Practice --- 栈和队列

155. 最小栈 设计一个支持 push ,pop ,top 操作,并能在常数时间内检索到最小元素的栈。 实现 MinStack 类: MinStack() 初始化堆栈对象。 void push(int val) 将元素val推入堆栈。 void pop() 删除堆栈顶部的元素。 int top() ......
队列 Leetcode Practice

kmp算法 字符串模式匹配

相关资料 例题 1.https://www.luogu.com.cn/problem/P3375 2.https://codeforces.com/problemset/problem/625/B ......
字符串 算法 字符 模式 kmp

leetcode-733-easy

Flood Fill An image is represented by an m x n integer grid image where image[i][j] represents the pixel value of the image. You are also given three ......
leetcode easy 733

leetcode-1005-easy

Maximize Sum Of Array After K Negations Given an integer array nums and an integer k, modify the array in the following way: choose an index i and rep ......
leetcode 1005 easy

leetcode-724-easy

Find Pivot Index Given an array of integers nums, calculate the pivot index of this array. The pivot index is the index where the sum of all the numbe ......
leetcode easy 724

leetcode-762-easy

Prime Number of Set Bits in Binary Representation Given two integers left and right, return the count of numbers in the inclusive range [left, right] ......
leetcode easy 762

leetcode-744-easy

Find Smallest Letter Greater Than Target You are given an array of characters letters that is sorted in non-decreasing order, and a character target. ......
leetcode easy 744

HJ65 查找两个字符串a,b中的最长公共子串_穷举查找字符串相同子串

思路:1、穷举查找字符串子串 2、把相同子串存入数组 3、生成新数组存储对应index的子串长度 4、返回第一个最长数组index,通过index查找子串输出。 1 import sys 2 s1=sys.stdin.readline().strip() 3 s2=sys.stdin.readlin ......
字符串 字符 两个 HJ 65

LeetCode 100 相同的树

LeetCode | 100.相同的树 给你两棵二叉树的根节点 p 和 q ,编写一个函数来检验这两棵树是否相同。 如果两个树在结构上相同,并且节点具有相同的值,则认为它们是相同的。 示例 1: 输入:p = [1,2,3], q = [1,2,3] 输出:true 示例 2: 输入:p = [1, ......
LeetCode 100

记录使用mybatis时踩到的坑-integer类型数据为0时,会判断为:等于空字符串为true

因为做查询操作时,需要设置为传入参数值才进行查询,于是判断条件是: status != null and status != '' 即mapper层的写法: <if test="status != null and status != ''">and status=#{status}</if> 但设 ......
空字符 mybatis integer 类型 数据

LeetCode 94 二叉树的中序遍历

LeetCode | 94.二叉树的中序遍历 给定一个二叉树的根节点 root ,返回 它的 中序 遍历 。 示例 1: 输入:root = [1,null,2,3] 输出:[1,3,2] 示例 2: 输入:root = [] 输出:[] 示例 3: 输入:root = [1] 输出:[1] 提示: ......
LeetCode 94

字符串和json对象之间的转换关系——一定不要再导错包

添加依赖 <!--fastjson依赖--> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.33</version> </dependency> 一定不要导错包 字 ......
字符串 字符 对象 之间 json

反转链表-leetcode92

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

3. 无重复字符的最长子串

力扣题目链接 给定一个字符串 s ,请你找出其中不含有重复字符的 最长子串 的长度。 示例 1: 输入: s = "abcabcbb" 输出: 3 解释: 因为无重复字符的最长子串是 "abc",所以其长度为 3。 示例 2: 输入: s = "bbbbb" 输出: 1 解释: 因为无重复字符的最长 ......
字符

438. 找到字符串中所有字母异位词

力扣题目链接 给定两个字符串 s 和 p,找到 s 中所有 p 的 异位词 的子串,返回这些子串的起始索引。不考虑答案输出的顺序。 异位词 指由相同字母重排列形成的字符串(包括相同的字符串)。 示例 1: 输入: s = "cbaebabacd", p = "abc" 输出: [0,6] 解释: 起 ......
字符串 字母 字符 438

0204 字符串相加

字符串的+操作 ​ 当+操作中出现字符串时,这个+就是字符串连接符,而不是算术运算符了,会将前后的数据进行拼接,并产生新的字符串。 连续加时 ​ 连续进行+操作时,从左到右逐个执行,只要在前面出现过字符串的+操作,后面即使出现数字相加也会视为字符串相加 System.out.println("abc ......
字符串 字符 0204

0106 特殊字符

特殊字符 \t ​ 制表符:tab键 ​ 在打印的时候,把前面字符串的长度补齐到8,或者8的整数倍,最少补1个空格,最多补8个。 特殊情况 ​ jdk的版本不同,其最多补几个空格的数量也会不同,jdk18则最多补4个 代码 public class tab { public static void ......
字符 0106

567. 字符串的排列

力扣题目链接 给你两个字符串 s1 和 s2 ,写一个函数来判断 s2 是否包含 s1 的排列。如果是,返回 true ;否则,返回 false 。 换句话说,s1 的排列之一是 s2 的 子串 。 示例 1: 输入:s1 = "ab" s2 = "eidbaooo" 输出:true 解释:s2 包 ......
字符串 字符 567

day8| 344.反转字符串;541.反转字符串II;剑指offer 05.替换空格;151.翻转字符串里的单词;剑指offer 58.左旋转字符串

344.反转字符串 题目简述: 编写一个函数,其作用是将输入的字符串反转过来。输入字符串以字符数组s的形式给出。不要给另外的数组分配额外的空间,你必须原地修改输入数组,使用O(1)的额外空间解决这一问题。 解题思路: 没什么好说的,直接双指针 代码如下: class Solution: def re ......
字符串 字符 左旋 offer 空格

LeetCode 2367 算术三元组的数目

给你一个下标从 0 开始、严格递增 的整数数组 nums 和一个正整数 diff 。如果满足下述全部条件,则三元组 (i, j, k) 就是一个 算术三元组 : i < j < k , nums[j] - nums[i] == diff 且 nums[k] - nums[j] == diff 返回不 ......
算术 数目 LeetCode 2367

全网最详细中英文ChatGPT-GPT-4示例文档-智能编写Python注释文档字符串从0到1快速入门——官网推荐的48种最佳应用场景(附python/node.js/curl命令源代码,小白也能学)

如果要给一个python函数写高质量的文档字符串,程序员不仅要需要在文档字符串中描述函数的参数和返回值,并使用相应的标签(例如Args,Returns,Raises)来提升可读性,还需要注意相关的语法规则和格式。而ChatGPT的智能注释文档生成功能,能帮助程序员智能创建注释文档字符串,极大地提高了... ......
文档 全网 示例 字符串 注释

【DP】LeetCode 62. 不同路径

题目链接 62. 不同路径 思路 代码 class Solution { public int uniquePaths(int m, int n) { int[][] dp = new int[m][n]; Arrays.fill(dp[0], 1); for(int i = 0; i < m; i ......
路径 LeetCode 62

leetcode top100-01

最好能说明一下为什么不怕重复。看评论里有很多人提出这个问题,说hash冲突。 我在这里解答一下这个问题。 1.每次写入时,判断条件 不是当前的key本身存不存在,而是key和 tag 之间的差值存不存在,这一点很重要。 2.题目命题说明了一点,假定只有一个解。也就是说重复元素再多都无所谓。 case ......
leetcode 100 top 01

leetcode top100 - 02

坑 转换成数字进行运算,最后转换成链表。可能会出现溢出的情况。 因为无论是int还是long类型表达的数字长度是有限的,而链表的长度是可以无限追加的。 解释是干扰你的,其实就是依次从低位到高位的进位过程 笔试思路 把链表依次填充到数组中,数组容易操作,然后逐位进行加法运算; 面试思路 使用链表的思路 ......
leetcode 100 top 02

Leetcode19. 删除链表的倒数第 N 个结点

19. 删除链表的倒数第 N 个结点 自己纯手写第一题,递归有点冗杂,开辟了虚拟头节点,而且要特别注意边界条件(当倒数第n个正好是头节点时)。 ** * Definition for singly-linked list. * struct ListNode { * int val; * ListN ......
结点 Leetcode 19

字符串常用方法

1.capitalize() 方法:将字符串的首字母大写。 str = "hello, world" print(str.capitalize()) 输出:Hello, world 2.casefold() 方法:将字符串转换为小写并删除所有大小写特有的字符,使字符串可以比较。 str = "Hel ......
字符串 字符 常用 方法

C#文档转为Base64位字符串

public static string DocumentToBase64Str(string fileName) { FileStream filestream = new FileStream(fileName, FileMode.Open); byte[] bt = new byte[file ......
字符串 字符 文档 Base 64

C# 实现List 转字符串并使用逗号隔开

以下代码作为例子来操作: List<int> list = new List<int>() { 1,2,3 }; ###方式1:使用for循环 string result = ""; for (int i = 0; i < list.Count; i++) { result = result + l ......
逗号 字符串 字符 List

Java中将List列表转换为字符串的三种方法

如何在 Java中将List 转换为 String。接下来使用Java 8 Streams Collectors api和String.join()方法将带有逗号分隔符或自定义分隔符的集合转换为字符串。这种转换是通过使用 java api 方法的简单步骤完成的。首先了解如何使用toString()方 ......
字符串 中将 字符 方法 Java