当前位置:网站首页>Likou 58 - Left Rotation String
Likou 58 - Left Rotation String
2022-08-02 11:45:00 【Zhang Ran Ran √】
Title description
The left rotation operation of a string is to transfer several characters in front of the string to the end of the string.Please define a function to implement the function of the left rotation operation of the string.For example, if you enter the string "abcdefg" and the number 2, the function will return the result "cdefgab" obtained by left-rotating it two places.
Solution ideas
- This problem is very simple, just need to figure out StringBuffer's interception string operation function substring();
- Take two strings separately and change the order before and after to spell them together to complete the question.
Input and output example

Code
class Solution {public String reverseLeftWords(String s, int n) {int len = s.length();StringBuffer sb = new StringBuffer();sb.append(s);String s1 = sb.substring(0,n);String s2 = sb.substring(n,len);String ss= s2+s1;return ss;}}边栏推荐
猜你喜欢

【MySQL系列】- LIKE查询 以%开头一定会让索引失效吗

How to technically ensure the quality of LED display?

Deep Learning 100 Examples - Convolutional Neural Network (CNN) for mnist handwritten digit recognition

CCF论文会议 IEEE 如何查询某个会议期刊的所有文章

X86函数调用模型分析
![[kali-information collection] (1.9) Metasploit + search engine tool Shodan](/img/d2/6fae03d7597daa908a6816abc34e04.png)
[kali-information collection] (1.9) Metasploit + search engine tool Shodan

excel 批量翻译-excel 批量函数公司翻译大全免费

Swift中什么时候不能用 () 代替 Void 来使用

FinClip | 来了, 2022 年 7 月更新大盘点

QT笔记——QT类反射机制简单学习
随机推荐
如何在 UE4 中制作一扇自动开启的大门
ASP.NET Core 6框架揭秘实例演示[31]:路由“高阶”用法
WPF 实现窗体抖动效果
go语言的接口
MySQL主从复制几个重要的启动选项
Axure谷歌浏览器扩展程序下载及安装方法(免翻墙)
Swift中什么时候不能用 () 代替 Void 来使用
大疆P4M云遮挡矫正
数字化转型中的低代码
Several reasons why applet plugins benefit developers
您应该知道的 Google Sheets 使用技巧
LeetCode第三题(Longest Substring Without Repeating Characters)三部曲之一
Jest 测试框架 beforeEach 的设计原理解析
npm run dev 和 npm run serve区别
QListView的使用
Create an application operation process using the kubesphere GUI
翁恺C语言程序设计网课笔记合集
STM32+MPU6050 Design Portable Mini Desktop Clock (Automatically Adjust Time Display Direction)
Oracle 19c 连接PDB
【项目管理技术的优势】