当前位置:网站首页>1403. 非递增顺序的最小子序列
1403. 非递增顺序的最小子序列
2022-08-04 14:29:00 【anieoo】
原题链接:1403. 非递增顺序的最小子序列
solution:
class Solution {
public:
vector<int> minSubsequence(vector<int>& nums) {
sort(nums.begin(), nums.end());
int sum = 0;
for(auto &x : nums) sum += x;
vector<int> res; //返回值
int s = 0,j = nums.size() - 1;
while(j >= 0 && s <= sum / 2) {
res.push_back(nums[j]);
s += nums[j--];
}
return res;
}
};边栏推荐
猜你喜欢

leetcode 48. Rotate Image (Medium)

MySQL【触发器】
![[The Art of Hardware Architecture] Study Notes (1) The World of Metastability](/img/ac/54e4e13d9df90e96933c69623b770e.png)
[The Art of Hardware Architecture] Study Notes (1) The World of Metastability

如何通过使用“缓存”相关技术,解决“高并发”的业务场景案例?

九州云出席领航者线上论坛,共话5G MEC边缘计算现状、挑战和未来

本周讨论用户体验:Daedalus 的 Nemo 加入 Ambire,探索加密海洋

第六届未来网络发展大会,即将开幕!

用于X射线聚焦的复合折射透镜

Redis 复习计划 - Redis主从数据一致性和哨兵机制

广告电商系统开发功能只订单处理
随机推荐
企业级优化
技术分享| 融合调度系统中的电子围栏功能说明
Rust from entry to proficient 04-variables
token 过期后,如何自动续期?
数据库恢复
Win11快速助手在哪里?Win11打开快速助手的方法
如何在ubuntu环境下安装postgresql并配置远程访问
idea permanent activation tutorial (new version)
属于程序猿的浪漫
ssm learning experience (final chapter)
Makefile 语法及使用笔记
阿里老鸟终于把测试用例怎么写说的明明白白了,小鸟必看
Crawler - basic use of selenium, no interface browser, other uses of selenium, cookies of selenium, crawler cases
Problem solving-->Online OJ (18)
Lixia Action | Kyushu Yunzhang Jinnan: Open source is not a movement for a few people, popularization is the source
MySQL【触发器】
【问题解决】QT更新组件出现 “要继续此操作,至少需要一个有效且已启用的储存库”
[The Art of Hardware Architecture] Study Notes (1) The World of Metastability
metaRTC5.0新版本支持mbedtls(PolarSSL)
[in-depth study of 4 g / 5 g / 6 g project - 50] : URLLC - 16 - the 3 GPP URLLC agreement, specification, technical principle of depth interpretation - 10 - high reliability technology - 1 - low codin