当前位置:网站首页>[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;
}
};
边栏推荐
- Zebras are recognized as dogs, and Stanford found the reason why AI made mistakes
- Asemi rectifier bridge umb10f parameters, umb10f specifications, umb10f package
- Myopia: take off or match glasses? These problems must be understood clearly first
- 于文文、胡夏等明星带你玩转派对 皮皮APP点燃你的夏日
- Slam learning notes - build a complete gazebo multi machine simulation slam from scratch (II)
- 【剑指 Offer 】57 - II. 和为s的连续正数序列
- nifi从入门到实战(保姆级教程)——flow
- Explore Cassandra's decentralized distributed architecture
- [proteus simulation] 74hc595+74ls154 drive display 16x16 dot matrix
- 近视:摘镜or配镜?这些问题必须先了解清楚
猜你喜欢

How to use AAB to APK and APK to AAB of Google play apps on the shelves

NFT new opportunity, multimedia NFT aggregation platform okaleido will be launched soon

QT serial port UI design and solution to display Chinese garbled code

Mixlab编辑团队招募队友啦~~

0214-27100 a day with little fluctuation

The mixlab editing team is recruiting teammates~~

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

Uploads labs range (with source code analysis) (under update)

MySQL single table field duplicate data takes the latest SQL statement

Unreal_ Datatable implements ID self increment and sets rowname
随机推荐
Central South University | through exploration and understanding: find interpretable features with deep reinforcement learning
Data driving of appium framework for mobile terminal automated testing
(Supplement) double pointer topic
Mysql 单表字段重复数据取最新一条sql语句
Develop team OKR in the way of "crowdfunding"
PHP CI(CodeIgniter)log级别设置
Multithread 02 thread join
[combinatorics] combinatorial identity (sum of variable upper terms 1 combinatorial identity | summary of three combinatorial identity proof methods | proof of sum of variable upper terms 1 combinator
Uploads labs range (with source code analysis) (under update)
Chinese translation of Tagore's floating birds (1~10)
Two sides of the evening: tell me about the bloom filter and cuckoo filter? Application scenario? I'm confused..
Alibaba P8 painstakingly sorted it out. Summary of APP UI automated testing ideas. Check it out
斑馬識別成狗,AI犯錯的原因被斯坦福找到了
远程办公之大家一同实现合作编辑资料和开发文档 | 社区征文
用同花顺炒股开户安全吗?
Visual SLAM algorithms: a survey from 2010 to 2016
记一次jar包冲突解决过程
AcWing 第58 场周赛
Mysql 将逗号隔开的属性字段数据由列转行
EditText request focus - EditText request focus