当前位置:网站首页>899. 有序队列
899. 有序队列
2022-08-03 11:59:00 【anieoo】
原题链接:899. 有序队列
solution:
class Solution {
public:
string orderlyQueue(string s, int k) {
string res = s;
if(k != 1) { //k != 1可以组合成任意最小的字典序字符串
sort(s.begin(), s.end());
return s;
} else {
int n = s.size();
for(int i = 0;i < n;i++) {
s.push_back(s[0]);
s.erase(s.begin());
res = min(res, s);
}
}
return res;
}
};边栏推荐
猜你喜欢

Explain the virtual machine in detail!JD.com produced HotSpot VM source code analysis notes (with complete source code)

字节最爱问的智力题,你会几道?

CDH6.3.2开启kerberos认证

FR9811S6 SOT-23-6 23V, 2A Synchronous Step-Down DC/DC Converter

After completing the interview and clearance collection of Alibaba, I successfully won the 15th Offer this year

LeetCode-1796. 字符串中第二大的数字

Redis发布订阅和数据类型

基于英雄联盟的知识图谱问答系统

GET 和 POST 有什么区别?

Five super handy phone open-source automation tools, which is suitable for you?
随机推荐
【Mysql】清理binlog日志的方法
基于英雄联盟的知识图谱问答系统
[论文阅读] (23)恶意代码作者溯源(去匿名化)经典论文阅读:二进制和源代码对比
-找树根-
LeetCode-48. 旋转图像
【倒计时5天】探索音画质量提升背后的秘密,千元大礼等你来拿
字节最爱问的智力题,你会几道?
FR9811S6 SOT-23-6 23V, 2A Synchronous Step-Down DC/DC Converter
Explain the virtual machine in detail!JD.com produced HotSpot VM source code analysis notes (with complete source code)
Objective - C code analysis of the deep and shallow copy
Five super handy phone open-source automation tools, which is suitable for you?
为什么越来越多的开发者放弃使用Postman,而选择Eolink?
学习软件测试需要掌握哪些知识点呢?
Matlab学习10-图像处理之傅里叶变换
LeetCode-142. 环形链表 II
数据库系统原理与应用教程(075)—— MySQL 练习题:操作题 151-159(十九):综合练习
记住用户名案例(js)
直播弱网优化
[错题]电路维修
I in mother's womb SOLO20 years