当前位置:网站首页>1403. Minimum Subsequence in Non-Increasing Order
1403. Minimum Subsequence in Non-Increasing Order
2022-08-04 14:36:00 【anieoo】
Original title link: 1403. Minimum subsequence in non-increasing order

solution:
class Solution {public:vector minSubsequence(vector& nums) {sort(nums.begin(), nums.end());int sum = 0;for(auto &x : nums) sum += x;vector res; //return valueint s = 0,j = nums.size() - 1;while(j >= 0 && s <= sum / 2) {res.push_back(nums[j]);s += nums[j--];}return res;}}; 边栏推荐
猜你喜欢
随机推荐
leetcode:254. 因子的组合
【问题解决】QT更新组件出现 “要继续此操作,至少需要一个有效且已启用的储存库”
阿里老鸟终于把测试用例怎么写说的明明白白了,小鸟必看
How to install postgresql and configure remote access in ubuntu environment
Redis 复习计划 - Redis主从数据一致性和哨兵机制
自监督学习未来是掩码自编码器?KAIST最新《自监督学习掩码自编码器》研究进展
爬虫——selenium基本使用、无界面浏览器、selenium的其他用法、selenium的cookie、爬虫案例
2042. 检查句子中的数字是否递增-力扣双百代码-设置前置数据
Bluetooth Technology|In the first half of the year, 1.3 million charging piles were added nationwide, and Bluetooth charging piles will become the mainstream of the market
谷歌插件.crx文件下载后被自动删除的解决方法
快解析结合千方百剂
G. Mountaineering Squad (violence & dfs)
Find My技术|防止你的宠物跑丢,苹果Find My技术可以帮到你
[机缘参悟-60]:《兵者,诡道也》-1-开篇:“死“与“生“都是天道
Theory 1: Deep Learning - Detailed Explanation of the LetNet Model
Database recovery
B. Construct a simple sequence (greedy)
1375. 二进制字符串前缀一致的次数-前序遍历法
如何确定异步 I/O 瓶颈
编程思想_编程有必要给孩子学吗?









