当前位置:网站首页>LeetCode 899 Ordered queue [lexicographical order] HERODING's LeetCode road
LeetCode 899 Ordered queue [lexicographical order] HERODING's LeetCode road
2022-08-03 11:11:00 【HERODING23】

Problem-solving ideas:
In fact, as long as you want to understand, it is a very simple problem. When k is equal to 1, then the string s can be imagined as a looping string, and the string that can be formed is any arbitrary string.The node is headed, and it is formed in order to the end. Find the smallest lexicographical order, k>1, then it is equivalent to the full arrangement of all characters, just sort directly, the code is as follows:
class Solution {public:string orderlyQueue(string s, int k) {if(k == 1) {int n = s.size();string minS = s;s += s;for(int i = 1; i <n; i ++) {string temp = s.substr(i, n);minS = min(minS, temp);}return minS;}sort(s.begin(), s.end());return s;}};边栏推荐
猜你喜欢
随机推荐
C#/VB.NET 从PDF中提取表格
Traceback (most recent call last): File
Cookie和Session使用
成为优秀架构师必备技能:怎样才能画出让所有人赞不绝口的系统架构图?秘诀是什么?快来打开这篇文章看看吧!...
The way of programmer architecture practice: how to design a sustainable evolution system architecture?
[Bubble sort and odd-even sorting]
Matplotlib
关于OPENSSL的问题
深度学习100例——卷积神经网络(CNN)实现服装图像分类
SmobilerService 推送实现
图新地球为什么很模糊,白球、看图、下载问题深度剖析
玉溪卷烟厂通过正确选择时序数据库 轻松应对超万亿行数据
历史拉链数据处理有人做过吗
[Output each bit of an integer, from high to low.With and without recursion]
谷歌实用插件分享
oracle计算同、环比
Cross-chain bridge protocol Nomad suffers hacker attack, losing more than $150 million
使用.NET简单实现一个Redis的高性能克隆版(一)
complete knapsack problem
LP流动性挖矿DAPP系统开发丨流动性挖矿功能原理及说明








