当前位置:网站首页>324. 摆动排序 II
324. 摆动排序 II
2022-06-28 17:38:00 【anieoo】
原题链接:324. 摆动排序 II
solution:
class Solution {
public:
void wiggleSort(vector<int>& nums) {
vector<int> res(nums);
sort(res.begin(),res.end());
int r = res.size() - 1,l = r / 2;
for(int i = 0;i < res.size();i++) {
if(i % 2 == 0) nums[i] = res[l--];
else nums[i] = res[r--];
}
}
};边栏推荐
- The fourth largest operator cannot be a "catfish"
- 如何从RHEL 8升级到RHEL 9
- How to put your WordPress website in maintenance mode
- Matlb| visual learning (plot and bar)
- Spark Tuning (submit job resource parameter tuning)
- Finally quit, full-time UE
- Xiaoxin black apple sound card ID injection
- The MySQL installed in Alibaba cloud server is version 8. Is it because the MySQL driver version of dataworks does not support it? Now mention
- Leetcode 6. Zigzag transformation (awesome, solved)
- Does DMS SQL result set export support parameter transfer?
猜你喜欢

Q: how bad can a programmer be?

第四个专栏,Kubernetes云原生实战,它来了~

2022起重机械指挥考试题库模拟考试平台操作

How to upgrade from RHEL 8 to RHEL 9

Nuc980 heartbeat light

全网最全360无死角编写软件测试用例模板【建议收藏】
![抓包整理外篇fiddler————了解工具栏[一]](/img/f4/fa909f30c0097fb77cea10eb0d3109.png)
抓包整理外篇fiddler————了解工具栏[一]

架构自治服务:构建数据驱动的架构洞察

Solve the problem of sqoop error manager SqlManager: Generic SqlManager. listDatabases() not implemented

Flutter tips: mediaquery and build optimization secrets you don't know
随机推荐
Nuc980 heartbeat light
IDC:阿里云获2021中国数据治理平台市场份额第一
Matlb| optimal operation and marketization of power system
为什么 insert 配置 'SELECT LAST_INSERT_ID()' 返回个0呢?
Flutter tips: mediaquery and build optimization secrets you don't know
Would you like to ask for advice on how to open a stock account? Is it safe to open an account online?
Redis principle - hash
9个优秀的占位图服务
数据库MySQL语句期末复习 CTGU
使用Pega进行一个简单的RPA程序开发
面部识别试验涉及隐私安全问题?国外一公司被紧急叫停
JQ plug-in analysis
Leetcode 6. Zigzag transformation (awesome, solved)
Advanced C language
2022年7月计划(全力unreal)
Google launches advanced API security to protect APIs from security threats
Ten MySQL locks, one article will give you full analysis
Google推出Advanced API Security 保护API免受安全威胁
9 excellent bitmap services
Does the dataworks SQL script support if else judgment of statement blocks