字符串 字符leetcode reverse

evalFn 字符串转执行函数 附带JSONParse函数

const evalFn = (fn) => { var Fun = Function // 一个变量指向Function,防止前端编译工具报错 return new Fun('return ' + fn)() } /** * * JSON反序列化,支持函数和 undefined * @param ......
函数 字符串 JSONParse 字符 evalFn

字符指针及其函数的使用

字符指针 一、字符指针的有关内容 首先需要明确的是,字符串实际就是字符数组。比如说: char p="hello world"; 实际上应该是: p={'h','e','l','l','o',' ','w','o','r','l','d','\0'}; 因此在定义字符串时,我们需将其看作是数组,也就 ......
指针 函数 字符

从字符串中分离文件路径,文件名及文件扩展名

从字符串中分离文件路径,文件名及文件扩展名 如一个文件:D:\文档\C#BASE\StringBuilder.md 要分离出文件路径:D:\文档\C#BASE\ 文件名:StringBuilder 文件扩展名:md 这是我们要拿到“\”和“.”这两个字符最后出现的索引 string path="D: ......
文件 扩展名 字符串 文件名 路径

Python中字符串格式化 - 快速写法

通过语法:f"内容{变量}"的格式来快速格式化 不理会类型 不做精度控制 name = "传智播客" setup_year = 2006 stock_price = 19.99 print(f"我是{name}, 我成立于:{setup_year},我今天的股价是{stock_price}") ......
写法 字符串 字符 格式 Python

Python中字符串格式化 - 数字精度控制

使用辅助符号“m.n”来控制数据的宽度和精度 m, 控制宽度,要求数字(很少使用),设置宽度小于数字自身,不生效 n, 控制小数精度,要求是数字,会进行小数的四舍五入 num1 = 11 num2 = 11.345 print("数字11宽度限制5,结果是%5d" % num1) print("数字 ......
字符串 精度 字符 格式 数字

Python中字符串格式化-练习题

练习题:计算股价小程序 name = "传智播客" stock_price = 19.99 stock_code = "003032" # 股票 价格 每日 增长 因子 stock_price_daily_growth_factor = 1.2 grow_days = 7 finally_stock ......
练习题 字符串 字符 格式 Python

Python中字符串格式化 - 表达式格式化

表达式:一条具有明确执行结果的代码语句 如: 1+1、8*2,就是表达式,结果是一个数字 格式化表达式: f"{表达式}" %s%d%f = % (表达式, 表达式, 表达式) print("1*1的结果是%d" % (1 * 1)) print(f"1 * 2的结果是{1 * 2}") print ......
格式 表达式 字符串 字符 Python

字符串的三种定义方式

单引号定义法 name = '我是hugh' print(type(name)) 双引号定义法 name = "我是hugh" print(type(name)) 三引号定义法 name = """ 我 是 hugh """ print(type(name)) ......
字符串 字符 方式

特殊不可见字符Unicode编码

unicode显示符号 \u2000 \u2001 \u2002 \u2003 \u2004 \u2005 \u2006 \u2007 \u2008 \u2009 \u200a \u200b ​ \u200c ‌ \u200d ‍ \u200e ‎ \u200f ‏ \u2010 ‐ \u2011 ......
字符 编码 Unicode

[LeetCode] 498. Diagonal Traverse 对角线遍历

题目 Given an m x n matrix mat, return an array of all the elements of the array in a diagonal order. 思考 最初在纸上写写画画试了很多想法,但都没能解决,真的。。太弱了T T。 后来在YT上看了个印度老 ......
对角线 对角 LeetCode Diagonal Traverse

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
共12000篇  :15/400页 首页上一页15下一页尾页