把数组排成最小的数
来源:互联网 发布:淘宝买到三无产品 编辑:程序博客网 时间:2024/06/04 19:49
链接:https://www.nowcoder.com/questionTerminal/8fecd3f8ba334add803bf2a06af1b993
来源:牛客网
来源:牛客网
class
Solution {
public
:
static
bool compare(
const
string &st1,
const
string &st2){
string s1 = st1+st2;
string s2 = st2+st1;
return
s1<s2;
}
string PrintMinNumber(vector<
int
> numbers) {
string result;
if
(numbers.size()<=
0
){
return
result;
}
vector<string> strNum;
for
(
int
i=
0
;i<numbers.size();i++ ){
stringstream ss;
ss<<numbers[i];
string s = ss.str();
strNum.push_back(s);
}
sort(strNum.begin(),strNum.end(),compare);
for
(
int
i=
0
;i<strNum.size();i++){
result.append(strNum[i]);
}
return
result;
}
};
两个数字内容的字符串会自动比较大小!!!???
阅读全文
0 0
- 把数组排成最小的数--总结
- 把数组排成最小的数
- 把数组排成最小的数
- 把数组排成最小的数
- 把数组排成最小的数--总结
- 把数组排成最小的数--总结
- 把数组排成最小的数
- 把数组排成最小的数
- 把数组排成最小的数
- 把数组排成最小的数
- 把数组排成最小的数
- 把数组排成最小的数
- 把数组排成最小的数
- 把数组排成最小的数
- 把数组排成最小的数
- 把数组排成最小的数
- 把数组排成最小的数
- 把数组排成最小的数
- 如何利用消息系统避免分布式事务
- Almost Union-Find ()
- 输入框聚焦失焦时,标签隐藏与显示
- 0.3 CSDN Markdown简明教程3-表格和公式
- Failed to load ApplicationContext异常java.lang.NoSuchMethodError
- 把数组排成最小的数
- Ignatius and the Princess II
- SecureCRT自动登录
- 广度优先搜索
- 你知道这些和Linux有关的物流操作系统吗?
- 0.4 CSDN Markdown简明教程4-UML图
- C++学习日记18——C++继承: 公有public, 私有private, 保护protect
- 关于@Requestbody的注解
- Python 对两个文件中数据的处理