当前位置:网站首页>2022.8.3-----leetcode.899
2022.8.3-----leetcode.899
2022-08-04 02:10:00 【Lk Lu727】
public String orderlyQueue(String s, int k) {//k is 1, only one beginning can be selected in the character ring of s to make it the smallestif (k == 1) {String smallest = s;String ss =s+s;int n = s.length();for (int i = 1; i < n; i++) {if(ss.substring(i,i+n).compareTo(smallest)<0)smallest=ss.substring(i,i+n);}return smallest;} else {//k>1, the order of any two adjacent characters can be exchanged, and finally all characters can be sortedchar[] arr = s.toCharArray();Arrays.sort(arr);return new String(arr);}}边栏推荐
- LeetCode:899. 有序队列【思维题】
- 大佬们,读取mysql300万单表要很长时间,有什么参数可以优惠,或者有什么办法可以快点
- 持续投入商品研发,叮咚买菜赢在了供应链投入上
- 一个注解替换synchronized关键字:分布式场景下实现方法加锁
- Continuing to invest in product research and development, Dingdong Maicai wins in supply chain investment
- 可变字符串
- C# 构造函数业务场景测试项目
- FileNotFoundException: This file can not be opened as a file descriptor; it is probably compressed
- activiti流程执行过程中,数据库表的使用关系
- 在更一般意义上验算移位距离和假设
猜你喜欢
随机推荐
实例036:算素数
C语言:学生管理系统(链表版)
STM32-遥感数据处理
MallBook联合人民交通出版社,推动驾培领域新发展,开启驾培智慧交易新生态
循环绕过问题
Taurus.MVC WebAPI 入门开发教程1:框架下载环境配置与运行(含系列目录)。
天地图坐标系转高德坐标系 WGS84转GCJ02
Day13 Postman的使用
深度学习(三)分类 理论部分
esp32发布机器人电池电压到ros2(micro-ros+CoCube)
多线程 之 JUC 学习篇章一 创建多线程的步骤
【云原生】DevOps(六):Jenkins流水线
sudo 权限控制,简易
Instance, 038: the sum of the diagonal matrix
JS 保姆级贴心,从零教你手写实现一个防抖debounce方法
第13章 网络安全漏洞防护技术原理与应用
initramfs详解----添加硬盘驱动并访问磁盘
MallBook 助力SKT思珂特教育集团,立足变化,拥抱敏捷交易
Qt中对象树的机制介绍以及底层实现,各种结果分析:(以及自己写容易犯错的点)
FileNotFoundException: This file can not be opened as a file descriptor; it is probably compressed









