当前位置:网站首页>[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;
}
};
边栏推荐
- Uploads labs range (with source code analysis) (under update)
- 切入点表达式
- 跟我学企业级flutter项目:简化框架demo参考
- 关于视觉SLAM的最先进技术的调查-A survey of state-of-the-art on visual SLAM
- 14 topics for performance interviews between superiors and subordinates (4)
- EditText request focus - EditText request focus
- 1287. Elements that appear more than 25% in an ordered array
- Acwing game 58
- Unreal_DataTable 实现Id自增与设置RowName
- Détails du contrôle de la congestion TCP | 3. Espace de conception
猜你喜欢

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

关于视觉SLAM的最先进技术的调查-A survey of state-of-the-art on visual SLAM

Getting started with Message Oriented Middleware

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

Colab works with Google cloud disk

The mixlab editing team is recruiting teammates~~

Slam learning notes - build a complete gazebo multi machine simulation slam from scratch (I)

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

Multithread 02 thread join

Slam learning notes - build a complete gazebo multi machine simulation slam from scratch (II)
随机推荐
Multithread 02 thread join
2022爱分析· 国央企数字化厂商全景报告
Qt插件之自定义插件构建和使用
Everyone in remote office works together to realize cooperative editing of materials and development of documents | community essay solicitation
《天天数学》连载56:二月二十五日
One article takes you to understand machine learning
Explore Cassandra's decentralized distributed architecture
Remote file contains actual operation
The mixlab editing team is recruiting teammates~~
Hong Kong Polytechnic University | data efficient reinforcement learning and adaptive optimal perimeter control of network traffic dynamics
Develop team OKR in the way of "crowdfunding"
Is it safe to open a stock account by mobile registration? Does it need money to open an account
特征多项式与常系数齐次线性递推
[combinatorics] combinatorial identities (sum of variable terms 3 combinatorial identities | sum of variable terms 4 combinatorial identities | binomial theorem + derivation to prove combinatorial ide
MySQL single table field duplicate data takes the latest SQL statement
Slam learning notes - build a complete gazebo multi machine simulation slam from scratch (II)
Golang 装饰器模式以及在NSQ中的使用
Record a jar package conflict resolution process
斑马识别成狗,AI犯错的原因被斯坦福找到了
Custom plug-in construction and use of QT plug-in