当前位置:网站首页>[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;
}
};
边栏推荐
- Cocos Creator 2.x 自动打包(构建 + 编译)
- 14 topics for performance interviews between superiors and subordinates (4)
- PyTorch 1.12发布,正式支持苹果M1芯片GPU加速,修复众多Bug
- Mb10m-asemi rectifier bridge mb10m
- Multithread 02 thread join
- Client does not support authentication protocol requested by server; consider upgrading MySQL client
- [combinatorics] combinatorial identities (sum of variable terms 3 combinatorial identities | sum of variable terms 4 combinatorial identities | binomial theorem + derivation to prove combinatorial ide
- Colab works with Google cloud disk
- 探索Cassandra的去中心化分布式架构
- Golang decorator mode and its use in NSQ
猜你喜欢

跟我学企业级flutter项目:简化框架demo参考

近视:摘镜or配镜?这些问题必须先了解清楚

Netease UI automation test exploration: airtest+poco

Détails du contrôle de la congestion TCP | 3. Espace de conception

Cocos Creator 2. X automatic packaging (build + compile)

0214-27100 a day with little fluctuation

Explore Netease's large-scale automated testing solutions see here see here

NSQ源码安装运行过程

Basis of target detection (IOU)

探索Cassandra的去中心化分布式架构
随机推荐
QT串口ui设计和解决显示中文乱码
1287. Elements that appear more than 25% in an ordered array
[solved] access denied for user 'root' @ 'localhost' (using password: yes)
斑馬識別成狗,AI犯錯的原因被斯坦福找到了
Unreal_ Datatable implements ID self increment and sets rowname
面试官:JVM如何分配和回收堆外内存
Unity project optimization case 1
Threejs Part 2: vertex concept, geometry structure
近视:摘镜or配镜?这些问题必须先了解清楚
利用MySQL中的乐观锁和悲观锁实现分布式锁
Mongodb installation and basic operation
NSQ源码安装运行过程
"Everyday Mathematics" serial 56: February 25
Zebras are recognized as dogs, and Stanford found the reason why AI made mistakes
Mixlab编辑团队招募队友啦~~
于文文、胡夏等明星带你玩转派对 皮皮APP点燃你的夏日
无心剑中译泰戈尔《漂鸟集(1~10)》
Multithread 02 thread join
Pointcut expression
高等数学(第七版)同济大学 习题2-1 个人解答