当前位置:网站首页>1413. Stepwise Summation to Get Minimum Positive Numbers
1413. Stepwise Summation to Get Minimum Positive Numbers
2022-08-10 06:34:00 【anieoo】
Original title link: 1413. Stepwise summation to get the minimum value of positive numbers
solution:
class Solution {public:int minStartValue(vector& nums) {int n = nums.size();vector prefix(n + 1);int s = INT_MAX;for(int i = 1;i <= n;i++) {prefix[i] = prefix[i - 1] + nums[i - 1];s = min(s, prefix[i]);}return s < 1 ? 1 - s : 1;}};
边栏推荐
猜你喜欢
随机推荐
NetKeeper(创翼)开WIFI方法——2018.5
761. 特殊的二进制序列
The difference between initializing objects as null and empty objects in JS
Can‘t find bundle for base name jdbc, locale zh_CN解决方法
进制的前缀表示和后缀表示
MySQL之InnoDB引擎(六)
如何在VMlogin中设置YiLu代理?
【论文解读】滴滴智能派单-KDD2018 Large-Scale Order Dispatch in On-Demand Ride-Hailing
关于MongoDb查询Decimal128转BigDecimal问题
Why do games need hot updates
2022河南萌新联赛第(五)场:信息工程大学 B - 交通改造
网页安全证书错误但无法安装证书的解决办法
pthread编程重要知识点
2022河南萌新联赛第(五)场:信息工程大学 C - 丢手绢
UE 游戏模式
C语言文件操作
ES13 - ES2022 - The 123rd ECMA Congress approves the ECMAScript 2022 language specification
请问为什么sqlserver cdc,任务启动过了一天,会报这个错误,明明已经开启cdc了。
2022河南萌新联赛第(五)场:信息工程大学 F - 分割草坪
DRM Memory Management