当前位置:网站首页>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;}};边栏推荐
猜你喜欢

LyScript implements memory stack scanning

Spinner文字显示不全解决办法

使用.NET简单实现一个Redis的高性能克隆版(一)

redis基础知识总结——数据类型(字符串,列表,集合,哈希,集合)

Why is the new earth blurred, in-depth analysis of white balls, viewing pictures, and downloading problems

巴比特 | 元宇宙每日必读:玩家离场,平台关停,数字藏品市场正逐渐降温,行业的未来究竟在哪里?...

如何通过DBeaver 连接 TDengine?

怎么在外头使用容器里php命令

跨链桥协议 Nomad 遭遇黑客攻击,损失超 1.5 亿美元

深度学习100例——卷积神经网络(CNN)实现服装图像分类
随机推荐
Skills required to be a good architect: How to draw a system architecture that everyone will love?What's the secret?Come and open this article to see it!...
实至名归!九章云极DataCanvas公司荣获智能制造领域多项殊荣
一文带你弄懂 CDN 技术的原理
鸿蒙第四次
【文件IO的简单实现】
微信多开批处理(自动获取安装路径)
深度学习经典网络 -- Inception系列(稀疏结构)
【冒泡排序以及奇数偶数排列】
机器学习(第一章)—— 特征工程
Who is more popular for hybrid products, depending on technology or market?
下午见!2022京东云数据库新品发布会
MATLAB programming and application 2.7 Structural data and unit data
【无标题】函数,对象,方法的区别
[华为云在线课程][SQL语法入门][学习笔记]
Programmers architecture practice way: software architecture basic concepts and thinking
fast planner中拓扑路径搜索
"Global Digital Economy Conference" landed in N World, Rongyun provides communication cloud service support
QT with OpenGL(HDR)
Matplotlib
Web Server 设置缓存响应字段的一些推荐方案