当前位置:网站首页>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;}};边栏推荐
- ERC20通证标准是什么?
- 卷起来!阿里高工携18位高级架构师耗时57天整合的1658页面试总结
- GBase 8c与openGauss是什么关系?
- Question G: Word Analysis ← Questions for the second provincial competition of the 11th Blue Bridge Cup Competition
- [Bubble sort and odd-even sorting]
- 巴比特 | 元宇宙每日必读:玩家离场,平台关停,数字藏品市场正逐渐降温,行业的未来究竟在哪里?...
- MATLAB programming and application 2.7 Structural data and unit data
- for in 和 for of的区别
- 深度学习100例——卷积神经网络(CNN)实现服装图像分类
- 507. 完美数
猜你喜欢

用于发票处理的 DocuWare,摆脱纸张和数据输入的束缚,自动处理所有收到的发票

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

MySQL - 2059 - Authentication plugin ‘caching_sha2_password‘ cannot be loaded

机器学习概述

本周四晚19:00知识赋能第4期直播丨OpenHarmony智能家居项目之设备控制实现

CADEditorX ActiveX 14.1.X

Machine Learning (Chapter 1) - Feature Engineering
![LeetCode 899 有序队列[字典序] HERODING的LeetCode之路](/img/95/1b63cfb25b9e0802666114f089fcb8.png)
LeetCode 899 有序队列[字典序] HERODING的LeetCode之路

Win10/11 删除文件资源管理器左侧栏目文件夹

Web Server 设置缓存响应字段的一些推荐方案
随机推荐
袋鼠云思枢:数驹 DTengine,助力企业构建高效的流批一体数据湖计算平台
Machines need tokens more than people
Android 技术面试准备(含面试题及答案)
在 Chrome 开发者工具里通过 network 选项模拟网站的离线访问模式
MATLAB程序设计与应用 2.6 字符串
像用户体验设计师一样思考
MATLAB Programming and Applications 2.6 Strings
oracle计算同、环比
混合型界面:对话式UI的未来
再谈“雷克萨斯”安全装置失效!安全手册疑点重重,网友:细思极恐
LeetCode第三题(Longest Substring Without Repeating Characters)三部曲之二
Cookie和Session使用
Who is more popular for hybrid products, depending on technology or market?
鸿蒙第三次
For invoice processing DocuWare, cast off the yoke of the paper and data input, automatic processing all the invoice received
Matplotlib
LeetCode 899 有序队列[字典序] HERODING的LeetCode之路
多态详细讲解(简单实现买票系统模拟,覆盖/重定义,多态原理,虚表)
如何改变sys_guid() 返回值类型
C#+WPF 单元测试项目类高级程序员必知必会