左旋 字符串 字符leetcode

C#中如何去掉字符串所有空格

在字符串操作中Trim方法只能去掉字符串对象前端和后端的空格,但是,如果空格出现在中间如何去除呢? 这里可以使用StringBuilder来操作字符串,StringBuilder操作字符串无疑是最为方便高效的。现在利用StringBuilder类中的Replace方法去掉字符串中所有的空格。 rep ......
空格 字符串 字符

[LeetCode Hot 100] LeetCode73. 矩阵置零

题目描述 思路一:开辟两个数组,时间复杂度O(m + n) 开辟两个数组用来记录哪些行、哪些列需要置为零。 这样时间复杂度为O(m + n)。 思路二: 原地算法:不适用额外空间或者说常数级空间来实现算法。 类似于使用set保存每行每列是否需要置零, 方法一:对应思路一 class Solution ......
LeetCode 矩阵 Hot 100 73

带通配符的字符串匹配

http://ica.openjudge.cn/function1/3/ const int N =1004; int n,m,f[N][N]; char a[N],b[N]; signed main(){ int i,j; cin>>a+1>>b+1; n=strlen(a+1); m=strle ......
通配符 字符串 字符

leetcode-1662-easy

Check If Two String Arrays are Equivalent 思路一:把第一个数组入队列,然后遍历比较第二个数组 public boolean arrayStringsAreEqual(String[] word1, String[] word2) { Deque<Charac ......
leetcode 1662 easy

leetcode-1732-easy

Find the Highest Altitude 思路一:直接遍历 public int largestAltitude(int[] gain) { int val = 0; int max = val; for (int i : gain) { val += i; max = Math.max( ......
leetcode 1732 easy

leetcode-1646-easy

Get Maximum in Generated Array You are given an integer n. A 0-indexed integer array nums of length n + 1 is generated in the following way: nums[0] = ......
leetcode 1646 easy

leetcode-2169-easy

Count Operations to Obtain Zero You are given two non-negative integers num1 and num2. In one operation, if num1 >= num2, you must subtract num2 from ......
leetcode 2169 easy

leetcode-2180-easy

Count Integers With Even Digit Sum Given a positive integer num, return the number of positive integers less than or equal to num whose digit sums are ......
leetcode 2180 easy

leetcode-1455-easy

Check If a Word Occurs As a Prefix of Any Word in a Sentence Given a sentence that consists of some words separated by a single space, and a searchWor ......
leetcode 1455 easy

leetcode-1464-easy

Maximum Product of Two Elements in an Array Given the array of integers nums, you will choose two different indices i and j of that array. Return the ......
leetcode 1464 easy

leetcode-1512-easy

Number of Good Pairs Given an array of integers nums, return the number of good pairs. A pair (i, j) is called good if nums[i] == nums[j] and i < j. E ......
leetcode 1512 easy

leetcode-1550-easy

Three Consecutive Odds Given an integer array arr, return true if there are three consecutive odd numbers in the array. Otherwise, return false. Examp ......
leetcode 1550 easy

leetcode-1572-easy

Matrix Diagonal Sum Given a square matrix mat, return the sum of the matrix diagonals. Only include the sum of all the elements on the primary diagona ......
leetcode 1572 easy

[LeetCode] 1688. Count of Matches in Tournament

You are given an integer n, the number of teams in a tournament that has strange rules: If the current number of teams is even, each team gets paired ......
Tournament LeetCode Matches Count 1688

Leetcode 80. 删除有序数组中的重复项 II

被前面类似的题禁锢了思路,自己写的双指针,感觉题解很巧妙,记录一下。这个解法不用记录cnt。 通用解法 为了让解法更具有一般性,我们将原问题的「保留 2 位」修改为「保留 k 位」。 对于此类问题,我们应该进行如下考虑: 由于是保留 k 个相同数字,对于前 k 个数字,我们可以直接保留 对于后面的任 ......
数组 Leetcode 80 II

Leetcode刷题day6-哈希表.双指针.三~四数求和.

454.四数相加Ⅱ 454. 四数相加 II - 力扣(LeetCode) 给你四个整数数组 nums1、nums2、nums3 和 nums4 ,数组长度都是 n ,请你计算有多少个元组 (i, j, k, l) 能满足: 0 <= i, j, k, l < n nums1[i] + nums2[ ......
指针 Leetcode day6 day

字符的编码方式(ASCII、ANSI、Unicode)

本篇博客大致介绍了字符的三种编码格式:ASCII、ANSI、Unicode,并比较浅显的解释了其编码过程,在写这篇博客的时候,参考了以下链接: 【字符编码】彻底理解字符编码 - leesf - 博客园 (cnblogs.com) 一篇搞懂Unicode ANSI UTF8等字符编码 - 知乎 (zh ......
字符 编码 Unicode 方式 ASCII

01-字符串

课程:字符串 目标 认识字符串 下标 切片 常用操作方法 一. 认识字符串 字符串是 Python 中最常用的数据类型。我们一般使用引号来创建字符串。创建字符串很简单,只要为变量分配一个值即可。 a = 'hello world' b = "abcdefg" print(type(a)) print ......
字符串 字符 01

[LeetCode Hot 100] LeetCode19. 删除链表的倒数第N个结点

题目描述 思路一:采用两次遍历 第一遍遍历先获取链表的长度length 第二次从dummy节点开始走length - n步 然后将该节点指向下下个节点 思路二:采用一次遍历 设置虚拟节点dummyHead指向head 设定双指针p和q,初始都指向虚拟节点dummyHead 移动q,直到p与q之间相隔 ......
LeetCode 结点 Hot 100 19

cw 字符串专题

KMP 和 AC 自动机都只会背板子怎么办啊 /kk。 模板 AC 自动机 不会,但我会背板子。 for(int i=0;i<26;i++) ch[0][i]=1; queue<int> q;q.push(1); while(!q.empty()) { int u=q.front();q.pop() ......
字符串 字符 专题 cw

[LeetCode Hot 100] LeetCode21. 合并两个有序链表

题目描述 思路:新建dummy去"穿针引线" 新建一个dummy节点去"穿针引线" 注意最后返回的是dummy.next 方法一: /** * Definition for singly-linked list. * public class ListNode { * int val; * List ......
LeetCode 两个 Hot 100 21

字符编码

字符编码 【1】阶段一:一家独大(ASCII) (1)ASCII表的诞生 现代计算机起源于美国,所以最先考虑仅仅是让计算机识别英文字符,于是诞生了ASCII表 (2)ASCII表的特点 只有英文字符与数字的一一对应关系 一个英文字符对应1Bytes,1Bytes=8bit,8bit最多包含256个数 ......
字符 编码

template包 字符串函数

字符串函数 https://blog.gmem.cc/gotpl 函数 说明 abbrev 缩写参数,超出的字符以...代替。例如 abbrev 5 "hello world"输出 he... abbrevboth abbrevboth N STR:从双侧缩写 trunc trunc N STR:截 ......
字符串 函数 字符 template

HTML学习笔记七:html-字符实体和全局属性

HTML学习笔记七:html-字符实体和全局属性 MDN元素查询地址 所有的html的元素我们都可以通过以下地址进行相关的查询和理解。 https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/meta 字符实体 用特定代码来表示一个符号,即 ......
全局 实体 字符 属性 笔记

RK3568,字符设备框架:管理同主设备号、不同次设备号设备

字符设备框架:管理同主设备号、不同次设备号设备 以下代码针对迅为开发板RK3568,开发板系统是ubuntu20.04, 正文 以下是我写的字符设备框架,实现了管理同主设备号、不同次设备号的功能。 代码: private_data_test.c #include <linux/init.h> #in ......
设备 主设备 字符 框架 3568

代码随想训练营第五十六天(Python)| 583. 两个字符串的删除操作、72. 编辑距离

583. 两个字符串的删除操作 class Solution: def minDistance(self, word1: str, word2: str) -> int: n, m = len(word1), len(word2) # dp 数组代表使得 word1 以 i-1 结尾和 word2 ......
训练营 字符串 随想 字符 两个

Java 时间戳与格式化字符串互转

直接看代码: import java.text.SimpleDateFormat; import java.util.Date; public class Timestamp2DateFormatUsage { public static void main(String[] args) { Sys ......
字符串 字符 格式 时间 Java

java字符串 加上n个"|--",与过滤处理

/***** * original,左边扩充n个"-" * @param n * @param original * @return */ private String fullStr(int n,String original){ StringBuilder sb = new StringBuil ......
quot 字符串 字符 java

[LeetCode Hot 100] LeetCode234. 回文链表

题目描述 思路1:将值复制到数组中然后使用双指针 计算链表的长度 创建等长的数组 将链表中的数依次放入数组中 使用左右指针判断链表是否是回文链表 时间复杂度:O(n) 空间复杂度:O(n) 思路2:快慢指针+反转链表 用快慢指针,快指针走两步,慢指针走一步,快指针遇到终止位置时,慢指针就在链表中间位 ......
LeetCode 回文 Hot 100 234

[LeetCode Hot 100] LeetCode206. 反转链表

题目描述 思路:双指针算法 方法一: /** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode() {} * ListNode(int val) ......
LeetCode Hot 100 206
共11000篇  :15/367页 首页上一页15下一页尾页