当前位置:网站首页>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);
}
}
边栏推荐
- System activity monitor ISTAT menus 6.61 (1185) Chinese repair
- matplotlib画柱状图并添加数值到图中
- App general function test cases
- Tourism Management System Based on jsp+servlet+mysql framework [source code + database + report]
- DAY ONE
- PostgreSQL highly available repmgr (1 master 2 slave +1witness) + pgpool II realizes master-slave switching + read-write separation
- 【2022全网最细】接口测试一般怎么测?接口测试的流程和步骤
- PostgreSQL高可用之repmgr(1主2从+1witness)+Pgpool-II实现主从切换+读写分离
- 17、 MySQL - high availability + read / write separation + gtid + semi synchronous master-slave replication cluster
- How to answer the dualistic opposition of Zhihu
猜你喜欢

Introduction au GPIO

1000字精选 —— 接口测试基础

After leaving a foreign company, I know what respect and compliance are

The largest single investment in the history of Dachen was IPO today

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

app通用功能測試用例

Introduction to GPIO

Every year, 200 billion yuan is invested in the chip field, and "China chip" venture capital is booming

DAY ONE

iMeta | 华南农大陈程杰/夏瑞等发布TBtools构造Circos图的简单方法
随机推荐
Use Yum or up2date to install the postgresql13.3 database
37页数字乡村振兴智慧农业整体规划建设方案
Pdf document signature Guide
服务器SMP、NUMA、MPP体系学习笔记。
[CVPR 2022] target detection sota:dino: Detr with improved detecting anchor boxes for end to end object detection
SuperSocket 1.6 创建一个简易的报文长度在头部的Socket服务器
【向量检索研究系列】产品介绍
Every year, 200 billion yuan is invested in the chip field, and "China chip" venture capital is booming
Wind chime card issuing network source code latest version - commercially available
48页数字政府智慧政务一网通办解决方案
在Docker中分分钟拥有Oracle EMCC 13.5环境
PostgreSQL highly available repmgr (1 master 2 slave +1witness) + pgpool II realizes master-slave switching + read-write separation
微信小程序uploadfile服务器,微信小程序之wx.uploadFile[通俗易懂]
[CVPR 2022] semi supervised object detection: dense learning based semi supervised object detection
Imeta | Chen Chengjie / Xia Rui of South China Agricultural University released a simple method of constructing Circos map by tbtools
What can the interactive slide screen demonstration bring to the enterprise exhibition hall
C语言输入/输出流和文件操作【二】
Use type aliases in typescript
[vector retrieval research series] product introduction
iMeta | 华南农大陈程杰/夏瑞等发布TBtools构造Circos图的简单方法