当前位置:网站首页>1844. replace all numbers with characters
1844. replace all numbers with characters
2022-06-24 08:52:00 【Drag is me】
leetcode Force button to brush questions and punch in
1844. Replace all numbers with characters
describe : I'll give you a subscript from 0 Starting string s , its even numbers Small letters at the subscript , Odd number The subscript is a number .
Define a function shift(c, x) , among c Is a character and x It's a number , Function returns to the alphabet c Next x Characters .
For example ,shift(‘a’, 5) = ‘f’ and shift(‘x’, 0) = ‘x’ .
For each Odd number Subscript i , You need to put the numbers s[i] use shift(s[i-1], s[i]) Replace .
Please replace all the numbers later , The string s return . subject Guarantee shift(s[i-1], s[i]) Not more than ‘z’ .
Their thinking
1、 The topic looks complicated , In fact, the water forced .
Source code ##
class Solution {
public:
string replaceDigits(string s) {
for (int i = 0; i < s.size(); ++i) {
if (i % 2 == 1) {
s[i] = s[i - 1] + s[i] - '0';
}
}
return s;
}
};
边栏推荐
- "Unusual proxy initial value setting is not supported", causes and Solutions
- 数据中台:数据采集和抽取的技术栈详解
- 【使用 PicGo+腾讯云对象存储COS 作为图床】
- 数据库迁移从PostgreSQL迁移到 MYSQL
- 110. balanced binary tree recursive method
- [quantitative investment] discrete Fourier transform to calculate array period
- opencv最大值滤波(不局限于图像)
- What is the future development trend of Business Intelligence BI
- 4274. 后缀表达式
- 关于ETL看这篇文章就够了,三分钟让你明白什么是ETL
猜你喜欢

【量化投资】离散傅里叶变换求数组周期

一文讲透,商业智能BI未来发展趋势如何

MySQL | store notes of Master Kong MySQL from introduction to advanced

【NOI模拟赛】寄(树形DP)

A tip to read on Medium for free

【NOI模拟赛】给国与时光鸡(构造)

À propos de ETL il suffit de lire cet article, trois minutes pour vous faire comprendre ce qu'est ETL

Distributed | how to make "secret calls" with dble

数据中台:数据采集和抽取的技术栈详解

2022-06-23:给定一个非负数组,任意选择数字,使累加和最大且为7的倍数,返回最大累加和。 n比较大,10的5次方。 来自美团。3.26笔试。
随机推荐
China chip Unicorn Corporation
MySQL | view notes on Master Kong MySQL from introduction to advanced
leetcode 1642. Furthest building you can reach
WebRTC系列-网络传输之5选择最优connection切换
第七章 操作位和位串(三)
Change SSH port number
MySQL | store notes of Master Kong MySQL from introduction to advanced
等保备案是什么意思?应该去哪里办理备案?
2022-06-23:给定一个非负数组,任意选择数字,使累加和最大且为7的倍数,返回最大累加和。 n比较大,10的5次方。 来自美团。3.26笔试。
What is the future development trend of Business Intelligence BI
数据库迁移从PostgreSQL迁移到 MYSQL
MySQL 因字符集问题插入中文数据时提示代码 :1366
解决:模型训练时loss出现nan
[pytoch basic tutorial 31] youtubednn model analysis
Camera projection matrix calculation
小程序云数据,数据请求一个集合数据的方法
Array opposite pointer series
剑指 Offer 55 - I. 二叉树的深度-dfs法
【使用 PicGo+腾讯云对象存储COS 作为图床】
Get screen width and height tool class