当前位置:网站首页>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;}}边栏推荐
- ansible module --copy module
- Several reasons why applet plugins benefit developers
- SQL 数据更新
- Golang map数组按字段分类
- List排序 ,取最大值最小值
- 【云驻共创】数据工坊平台,0代码开发数据处理业务“快”人一步
- npm WARN config global `--global`, `--local` are deprecated. Use `--location解决方案
- Challenge LeetCode1000 questions in 365 days - Day 047 Design Circular Queue Circular Queue
- Create a devops CI/CD process using the kubesphere GUI
- 元宇宙“吹鼓手”Unity:疯狂扩局,悬念犹存
猜你喜欢

How to connect TDengine through DBeaver?

Create a devops CI/CD process using the kubesphere GUI

看我如何用多线程,帮助运营小姐姐解决数据校对系统变慢!

QListView的使用

CAN总线的AUTOSAR网络管理

Shell编程案例

基于threejs的商品VR展示平台的设计与实现思路
[email protected] This version of tar is no longer supported, and will not receive"/>npm WARN deprecated [email protected] This version of tar is no longer supported, and will not receive

字母交换--字符串dp

10份重磅报告 — 展望中国数字经济未来
随机推荐
AdguardHome如何配置设置?我的AdguardHome配置内容过滤器拦截列表
网站自动翻译-网站批量自动翻译-网站免费翻译导出
看我如何用多线程,帮助运营小姐姐解决数据校对系统变慢!
运行yum报错Error: Cannot retrieve metalink for reposit
SQL 数据更新
QAbstractScrollArea、QScrollArea
Deep Learning 100 Examples - Convolutional Neural Network (CNN) for mnist handwritten digit recognition
ansible module --yum module
Create a devops CI/CD process using the kubesphere GUI
SQL函数 TRIM
从幻核疑似裁撤看如何保证NFT的安全
元宇宙“吹鼓手”Unity:疯狂扩局,悬念犹存
openresty 性能优化
ansible模块--copy模块
yolo格式(txt)数据集转VOC(xml)
SQLAlchemy使用教程
【云驻共创】数据工坊平台,0代码开发数据处理业务“快”人一步
The sitcom "Re-Walking the Long March" was staged
npm run serve启动报错npm ERR Missing script “serve“
大疆P4M云遮挡矫正