当前位置:网站首页>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;}};
边栏推荐
猜你喜欢
全新的Uber App设计
Depth study of 100 cases - convolution neural network (CNN) to realize the clothing image classification
鸿蒙第三次
程序员架构修炼之道:如何设计出可持续演进的系统架构?
玉溪卷烟厂通过正确选择时序数据库 轻松应对超万亿行数据
3分钟实现内网穿透(基于ngrok实现)
完全背包问题
Babbitt | Metaverse daily must-read: Players leave, platforms are shut down, and the digital collection market is gradually cooling down. Where is the future of the industry?...
ABAB-740新语法
CADEditorX ActiveX 14.1.X
随机推荐
[错题]电路维修
GBase 8c与openGauss是什么关系?
如何将Oracle/MySQL中的数据迁移到GBase 8c中?
机器比人更需要通证
Cross-chain bridge protocol Nomad suffers hacker attack, losing more than $150 million
【LeetCode—第2题 两数之和 代码详解 】附有源码,可直接复制
请问应该用什么关键字将内容主题设置为 dark 呢
玉溪卷烟厂通过正确选择时序数据库 轻松应对超万亿行数据
LyScript 实现对内存堆栈扫描
机器学习概述
【多线程的相关内容】
Summary of redis basics - data types (strings, lists, sets, hashes, sets)
Win10/11 删除文件资源管理器左侧栏目文件夹
MATLAB程序设计与应用 2.6 字符串
Boolean 与numeric 无法互转
跨链桥协议 Nomad 遭遇黑客攻击,损失超 1.5 亿美元
LP流动性挖矿DAPP系统开发丨流动性挖矿功能原理及说明
Babbitt | Metaverse daily must-read: Players leave, platforms are shut down, and the digital collection market is gradually cooling down. Where is the future of the industry?...
VRRP协议的作用及VRRP+OSPF配置方法
ERC20通证标准是什么?