当前位置:网站首页>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);}}
边栏推荐
猜你喜欢
随机推荐
多线程 之 JUC 学习篇章一 创建多线程的步骤
Multithreading JUC Learning Chapter 1 Steps to Create Multithreading
Hey, I had another fight with HR in the small group!
5.scrapy中间件&分布式爬虫
cdh6.x 集成spark-sql
Simple sorting (summer vacation daily question 14)
Example 035: Setting the output color
网页三维虚拟展厅为接入元宇宙平台做基础
idea中diagram使用
Summary of GNSS Articles
云开发旅游打卡广场微信小程序源码(含视频教程)
静态/动态代理模式
Flink jdbc connector 源码改造sink之 clickhouse多节点轮询写与性能分析
Sky map coordinate system to Gaode coordinate system WGS84 to GCJ02
ssh服务详解
脚手架内容详解分析
2022.8.3-----leetcode.899
Day13 Postman的使用
Continuing to pour money into commodities research and development, the ding-dong buy vegetables in win into the supply chain
Example 040: Reverse List