当前位置:网站首页>[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;
}
};
边栏推荐
- Google Earth engine (GEE) - daymet v4: daily surface weather data set (1000m resolution) including data acquisition methods for each day
- 2022 love analysis · panoramic report of digital manufacturers of state-owned enterprises
- Unreal_ Datatable implements ID self increment and sets rowname
- arduino-esp32:LVGL项目(一)整体框架
- PHP二级域名session共享方案
- 近视:摘镜or配镜?这些问题必须先了解清楚
- Uploads labs range (with source code analysis) (under update)
- Custom plug-in construction and use of QT plug-in
- Top k questions of interview
- MongoDB 的安装和基本操作
猜你喜欢
Record a jar package conflict resolution process
First knowledge of database
QT串口ui设计和解决显示中文乱码
Unreal_ Datatable implements ID self increment and sets rowname
消息队列消息丢失和消息重复发送的处理策略
Record windows10 installation tensorflow-gpu2.4.0
Learn from me about the enterprise flutter project: simplified framework demo reference
8个酷炫可视化图表,快速写出老板爱看的可视化分析报告
[combinatorics] non descending path problem (outline of non descending path problem | basic model of non descending path problem | non descending path problem expansion model 1 non origin starting poi
Slam learning notes - build a complete gazebo multi machine simulation slam from scratch (III)
随机推荐
Google Earth engine (GEE) - daymet v4: daily surface weather data set (1000m resolution) including data acquisition methods for each day
Mongodb installation and basic operation
利用MySQL中的乐观锁和悲观锁实现分布式锁
跟我学企业级flutter项目:简化框架demo参考
Initial test of scikit learn Library
A survey of state of the art on visual slam
【剑指 Offer】58 - I. 翻转单词顺序
One article takes you to understand machine learning
Mixlab编辑团队招募队友啦~~
The mixlab editing team is recruiting teammates~~
什么是质押池,如何进行质押呢?
Batch files: list all files in a directory with relative paths - batch files: list all files in a directory with relative paths
Slam learning notes - build a complete gazebo multi machine simulation slam from scratch (II)
Develop team OKR in the way of "crowdfunding"
Qt插件之自定义插件构建和使用
How to set up SVN server on this machine
Chinese translation of Tagore's floating birds (1~10)
Unreal_ Datatable implements ID self increment and sets rowname
Pointcut expression
一台服务器最大并发 tcp 连接数多少?65535?