当前位置:网站首页>[Jianzhi offer] 58 - ii Rotate string left
[Jianzhi offer] 58 - ii Rotate string left
2022-07-03 16:32:00 【LuZhouShiLi】
The finger of the sword Offer 58 - II. Left rotation string
subject
The left rotation operation of string is to transfer several characters in front of string to the end of string . Please define a function to implement the left rotation operation of string . such as , Input string "abcdefg" And number 2, This function will return the result of rotating two bits to the left "cdefgab".
Ideas
- Before reversal N character string
- reverse n String after
- Invert the entire string
Code
class Solution {
public:
string reverseLeftWords(string s, int n) {
// Before reversal N character string
reverse(s.begin(),s.begin() + n);
// reverse n String after
reverse(s.begin() + n,s.end());
// Invert the entire string
reverse(s.begin(),s.end());
return s;
}
};
边栏推荐
- 于文文、胡夏等明星带你玩转派对 皮皮APP点燃你的夏日
- [combinatorics] combinatorial identities (review of eight combinatorial identities | product of combinatorial identities 1 | proof | use scenario | general method for finding combinatorial numbers)
- 程序猿如何快速成长
- Hibernate的缓存机制/会话级缓存机制
- 面试之 top k问题
- Data driving of appium framework for mobile terminal automated testing
- Explore Netease's large-scale automated testing solutions see here see here
- Page dynamics [2]keyframes
- Eleven requirements for test management post
- MySQL single table field duplicate data takes the latest SQL statement
猜你喜欢

First knowledge of database

2022 love analysis · panoramic report of digital manufacturers of state-owned enterprises

Deep understanding of grouping sets statements in SQL

Stm32f103c8t6 firmware library lighting

Myopia: take off or match glasses? These problems must be understood clearly first

线程池执行定时任务

TCP擁塞控制詳解 | 3. 設計空間

ThreeJS 第二篇:顶点概念、几何体结构

Le zèbre a été identifié comme un chien, et la cause de l'erreur d'AI a été trouvée par Stanford

Learn from me about the enterprise flutter project: simplified framework demo reference
随机推荐
疫情常态化大背景下,关于远程办公的思考|社区征文
LeetCode1491. Average value of wages after removing the minimum wage and the maximum wage
MongoDB 的安装和基本操作
Chinese translation of Tagore's floating birds (1~10)
面试之 top k问题
消息队列消息丢失和消息重复发送的处理策略
AcWing 第58 场周赛
【声明】关于检索SogK1997而找到诸多网页爬虫结果这件事
什么是质押池,如何进行质押呢?
PHP中register_globals参数设置
手机注册股票开户安全吗 开户需要钱吗
[proteus simulation] 8 × 8LED dot matrix screen imitates elevator digital scrolling display
拼夕夕二面:说说布隆过滤器与布谷鸟过滤器?应用场景?我懵了。。
用同花顺炒股开户安全吗?
[combinatorics] combinatorial identities (sum of variable terms 3 combinatorial identities | sum of variable terms 4 combinatorial identities | binomial theorem + derivation to prove combinatorial ide
Data driving of appium framework for mobile terminal automated testing
8 tips for effective performance evaluation
程序猿如何快速成长
Is it safe to open a stock account by mobile registration? Does it need money to open an account
相同切入点的抽取