当前位置:网站首页>Sword finger offer II 012 The sum of left and right subarrays is equal
Sword finger offer II 012 The sum of left and right subarrays is equal
2022-06-25 17:04:00 【Python ml】
The finger of the sword Offer II 012. The sum of the left and right subarrays is equal
class Solution {
public:
int pivotIndex(vector<int>& nums) {
int total=accumulate(nums.begin(),nums.end(),0);
int sum=0;
for(int i=0;i<nums.size();++i){
if(2*sum+nums[i]==total)
return i;
sum+=nums[i];
}
return -1;
}
};
边栏推荐
猜你喜欢

使用PyWebIO测试,刚入门的测试员也能做出自己的测试工具

剑指 Offer 39. 数组中出现次数超过一半的数字

Paper notes: lbcf: a large scale budget constrained causal forest algorithm

Kotlin

Kotlin

App测试工具大全,收藏这篇就够了

Do you know all the configurations of pychrm?

Sword finger offer 39 Numbers that occur more than half the time in the array

剑指 Offer 50. 第一个只出现一次的字符

Uncover ges super large scale graph computing engine hyg: Graph Segmentation
随机推荐
效应与定律
DDD概念复杂难懂,实际落地如何设计代码实现模型?
[proficient in high concurrency] deeply understand the basis of C language and C language under assembly
剑指 Offer 39. 数组中出现次数超过一半的数字
The role of the project manager in the project
旧手机变废为宝,充当服务器使用
Are these old system codes written by pigs?
redis 分布式锁整理
3年,我是如何涨薪到20k?
MySQL 用 limit 为什么会影响性能?
pytorch官方文档学习记录
Which is better for intermediate and advanced soft exam?
Paper notes: lbcf: a large scale budget constrained causal forest algorithm
【剑指 Offer II 091. 粉刷房子】
Paper notes: generalized random forests
软件测试面试如何正确谈薪
Day_ seventeen
[proficient in high concurrency] deeply understand the basics of assembly language
Pytorch official document learning record
Differences between et al and etc