当前位置:网站首页>Leecode brush question record sword finger offer 58 - ii Rotate string left
Leecode brush question record sword finger offer 58 - ii Rotate string left
2022-07-07 00:12:00 【Why is there a bug list】
topic
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".
Example 1:
Input : s = “abcdefg”, k = 2
Output : “cdefgab”
Example 2:
Input : s = “lrloseumgh”, k = 6
Output : “umghlrlose”
Limit :
1 <= k < s.length <= 10000
answer
class Solution {
public String reverseLeftWords(String s, int n) {
char[] chars=s.toCharArray();
char[] tmpchars=new char[n];
int i=0;
for(; i< tmpchars.length; i++)
{
tmpchars[i]=chars[i];
}
for(int j=n;j<s.length();j++)
{
chars[j-n]=chars[j];
}
i=0;
for(int k=s.length()-n;k<s.length();k++)
{
chars[k]=tmpchars[i];
i++;
}
return new String(chars);
}
}
边栏推荐
- 快讯 l Huobi Ventures与Genesis公链深入接洽中
- Competition between public and private chains in data privacy and throughput
- 沉浸式投影在线下展示中的三大应用特点
- openresty ngx_lua子请求
- Basic chart interpretation of "Oriental selection" hot out of circle data
- okcc呼叫中心的订单管理时怎么样的
- Use Yum or up2date to install the postgresql13.3 database
- 《LaTex》LaTex数学公式简介「建议收藏」
- GEO数据挖掘(三)使用DAVID数据库进行GO、KEGG富集分析
- The "white paper on the panorama of the digital economy" has been released with great emphasis on the digitalization of insurance
猜你喜欢

What can the interactive slide screen demonstration bring to the enterprise exhibition hall

DAY ONE

How rider uses nuget package offline

Designed for decision tree, the National University of Singapore and Tsinghua University jointly proposed a fast and safe federal learning system

Three application characteristics of immersive projection in offline display

Server SMP, NUMA, MPP system learning notes.

服务器SMP、NUMA、MPP体系学习笔记。

DevOps可以帮助减少技术债务的十种方式

Rider离线使用Nuget包的方法

The "white paper on the panorama of the digital economy" has been released with great emphasis on the digitalization of insurance
随机推荐
Common modification commands of Oracle for tables
[2022 the finest in the whole network] how to test the interface test generally? Process and steps of interface test
在Docker中分分钟拥有Oracle EMCC 13.5环境
DAY ONE
Things like random
Eureka Client启动后就关闭 Unregistering application xxx with eureka with status DOWN
Three sentences to briefly introduce subnet mask
Pdf document signature Guide
What is a responsive object? How to create a responsive object?
MVC and MVVM
Oracle中使用包FY_Recover_Data.pck来恢复truncate误操作的表
快手的新生意,还得靠辛巴吆喝?
app通用功能測試用例
Local deployment Zeppelin 0.10.1
在docker中快速使用各个版本的PostgreSQL数据库
华为mate8电池价格_华为mate8换电池后充电巨慢
How can computers ensure data security in the quantum era? The United States announced four alternative encryption algorithms
Use package FY in Oracle_ Recover_ Data. PCK to recover the table of truncate misoperation
Zero code and high return. How to use 40 sets of templates to meet 95% of the reporting needs in the work
DAY FOUR