当前位置:网站首页>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;}};边栏推荐
- 微信小程序获取用户手机号码
- Cookie和Session使用
- Who is more popular for hybrid products, depending on technology or market?
- Analysis of the idea of the complete knapsack problem
- Binary search tree (search binary tree) simulation implementation (there is a recursive version)
- Web Server 设置缓存响应字段的一些推荐方案
- C - 为什么指针常常初始化为 NULL?
- oracle计算同、环比
- Advanced use of MySQL database
- for in 和 for of的区别
猜你喜欢

numpy

鸿蒙第四次

图新地球为什么很模糊,白球、看图、下载问题深度剖析

QT with OpenGL(HDR)

Basic using MySQL database

苏州大学:从PostgreSQL到TDengine

The way of programmer architecture practice: how to design a sustainable evolution system architecture?

袋鼠云思枢:数驹 DTengine,助力企业构建高效的流批一体数据湖计算平台

Polymorphism in detail (simple implementation to buy tickets system simulation, covering/weight definition, principle of polymorphism, virtual table)

Matplotlib
随机推荐
[错题]电路维修
VRRP协议的作用及VRRP+OSPF配置方法
如何将Oracle/MySQL中的数据迁移到GBase 8c中?
创建C UDR时,指定的HANDLESNULLS的作用是什么?
通过组策略安装软件和删除用户配置文件
【文件IO的简单实现】
for in 和 for of的区别
numpy
oracle计算同、环比
白帽黑客与留守儿童破壁对“画”!ISC、中国光华科技基金会、光明网携手启动数字安全元宇宙公益展
完全背包问题
试题G:单词分析 ← 第十一届蓝桥杯大赛第二场省赛赛题
507. 完美数
CADEditorX ActiveX 14.1.X
509. 斐波那契数
完全背包问题的思路解析
玉溪卷烟厂通过正确选择时序数据库 轻松应对超万亿行数据
OS层面包重组失败过高,数据库层面gc lost 频繁
用于发票处理的 DocuWare,摆脱纸张和数据输入的束缚,自动处理所有收到的发票
数据库一席谈:打造开源的数据生态,支撑产业数字化浪潮