当前位置:网站首页>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;}};
边栏推荐
- 下午见!2022京东云数据库新品发布会
- OS层面包重组失败过高,数据库层面gc lost 频繁
- 干货!一种被称为Deformable Butterfly(DeBut)的高度结构化且稀疏的线性变换
- ERC20通证标准是什么?
- ScrollView嵌套RecyclerView滚动冲突
- Machine Learning (Chapter 1) - Feature Engineering
- "Global Digital Economy Conference" landed in N World, Rongyun provides communication cloud service support
- 【网络原理的概念】
- 鸿蒙第三次
- 机器比人更需要通证
猜你喜欢
玉溪卷烟厂通过正确选择时序数据库 轻松应对超万亿行数据
通过组策略安装软件和删除用户配置文件
鸿蒙第三次
CADEditorX ActiveX 14.1.X
Simple implementation of a high-performance clone of Redis using .NET (1)
苏州大学:从PostgreSQL到TDengine
下午见!2022京东云数据库新品发布会
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!...
Fastjson反序列化
【JS 逆向百例】某网站加速乐 Cookie 混淆逆向详解
随机推荐
ARIMA实现(亲测可用)
2022年五面蚂蚁、三面拼多多、字节跳动最终拿offer入职拼多多
通过组策略安装软件和删除用户配置文件
通过GBase 8c Platform安装数据库集群时报错
C - 为什么指针常常初始化为 NULL?
鸿蒙第四次
卷起来!阿里高工携18位高级架构师耗时57天整合的1658页面试总结
【无标题】函数,对象,方法的区别
Simple implementation of a high-performance clone of Redis using .NET (1)
MySQL数据库高级使用
创建C UDR时,指定的HANDLESNULLS的作用是什么?
Who is more popular for hybrid products, depending on technology or market?
多态详细讲解(简单实现买票系统模拟,覆盖/重定义,多态原理,虚表)
用于发票处理的 DocuWare,摆脱纸张和数据输入的束缚,自动处理所有收到的发票
507. 完美数
[错题]电路维修
How to use outside the PHP command in the container
机器比人更需要通证
【冒泡排序以及奇数偶数排列】
干货!一种被称为Deformable Butterfly(DeBut)的高度结构化且稀疏的线性变换