当前位置:网站首页>2022.8.4-----leetcode.1403
2022.8.4-----leetcode.1403
2022-08-05 03:08:00 【路Lu727】
public List<Integer> minSubsequence(int[] nums) {
int n=nums.length;
List<Integer> ans=new ArrayList<>();
int sum=0;
for(int i=0;i<n;i++){
sum+=nums[i];
}
Arrays.sort(nums);
int tmp=0;
for(int i=n-1;i>=0;i--){
tmp+=nums[i];
ans.add(nums[i]);
if(tmp>sum/2)
break;
}
return ans;
}
边栏推荐
- 从“能用”到“好用” 国产软件自主可控持续推进
- Hash table lookup (hash table)
- 汉字转拼音
- Everyone in China said data, you need to focus on core characteristic is what?
- 软链接引发的物理备份问题
- ASP.NET应用程序--Hello World
- 2022 High-level installation, maintenance, and removal of exam questions mock exam question bank and online mock exam
- QT:神奇QVarient
- 【Daily Training】1403. Minimum Subsequence in Non-Increasing Order
- Physical backup issues caused by soft links
猜你喜欢
How to sort multiple fields and multiple values in sql statement
OpenGL 工作原理
In 2022, you still can't "low code"?Data science can also play with Low-Code!
人人都在说的数据中台,你需要关注的核心特点是什么?
倒计时 2 天|云原生 Meetup 广州站,等你来!
[Solved] Unity Coroutine coroutine is not executed effectively
Intersection of Boolean Operations in SuperMap iDesktop.Net - Repairing Complex Models with Topological Errors
word分栏小记
基于生长的棋盘格角点检测方法
Data storage practice based on left-order traversal
随机推荐
Physical backup issues caused by soft links
你要的七夕文案,已为您整理好!
Flink 1.15.1 Cluster Construction (StandaloneSession)
人人都在说的数据中台,你需要关注的核心特点是什么?
22-07-31周总结
[Qixi Festival] Romantic Tanabata, code teaser.Turn love into a gorgeous three-dimensional scene and surprise her (him)!(send code)
dmp (dump) dump file
【 genius_platform software platform development 】 : seventy-six vs the preprocessor definitions written cow force!!!!!!!!!!(in the other groups conding personnel told so cow force configuration to can
How to solve the error cannot update secondary snapshot during a parallel operation when the PostgreSQL database uses navicat to open the table structure?
1484. 按日期分组销售产品
The problem of lack of dynamic library "libtinfo.so.5" in ksql application under UOS system
数学-求和符号的性质
数据增强Mixup原理与代码解读
627. 变更性别
In 2022, you still can't "low code"?Data science can also play with Low-Code!
Hash table lookup (hash table)
The usage of try...catch and finally in js
PostgreSQL数据库 用navicat 打开表结构的时候报错 cannot update secondarysnapshot during a parallel operation 怎么解决?
How OpenGL works
QT语言文件制作