当前位置:网站首页>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;}};
边栏推荐
- oracle计算同、环比
- Classical Architecture and Memory Classification of Embedded Software Components
- 试题G:单词分析 ← 第十一届蓝桥杯大赛第二场省赛赛题
- [Explanation of JDBC and inner classes]
- How to use outside the PHP command in the container
- 巴比特 | 元宇宙每日必读:玩家离场,平台关停,数字藏品市场正逐渐降温,行业的未来究竟在哪里?...
- 二叉搜索树(搜索二叉树)模拟实现(有递归版本)
- 鸿蒙第三次
- gbase在轨道交通一般都采用哪种高可用架构?
- Depth study of 100 cases - convolution neural network (CNN) to realize the clothing image classification
猜你喜欢
LyScript 实现对内存堆栈扫描
谷歌实用插件分享
2022年五面蚂蚁、三面拼多多、字节跳动最终拿offer入职拼多多
LeetCode 899 有序队列[字典序] HERODING的LeetCode之路
Advanced use of MySQL database
for in 和 for of的区别
C#/VB.NET 从PDF中提取表格
Machine Learning (Chapter 1) - Feature Engineering
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!...
MySQL数据库高级使用
随机推荐
Win10/11 删除文件资源管理器左侧栏目文件夹
程序员架构修炼之道:软件架构基本概念和思维
机器学习概述
【LeetCode—第2题 两数之和 代码详解 】附有源码,可直接复制
直播弱网优化
【冒泡排序以及奇数偶数排列】
Cross-chain bridge protocol Nomad suffers hacker attack, losing more than $150 million
MySQL数据库高级使用
What is the relationship between The Matrix and 6G?
How to retrieve IDC research reports?
Web Server 设置缓存响应字段的一些推荐方案
MATLAB程序设计与应用 2.7 结构数据与单元数据
Traceback (most recent call last): File
【多线程的相关内容】
苏州大学:从PostgreSQL到TDengine
LeetCode第三题(Longest Substring Without Repeating Characters)三部曲之二
关于OPENSSL的问题
LP流动性挖矿DAPP系统开发丨流动性挖矿功能原理及说明
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!...
嵌入式软件组件经典架构与存储器分类