当前位置:网站首页>724. 寻找数组的中心下标
724. 寻找数组的中心下标
2022-07-04 05:07:00 【anieoo】
原题链接:724. 寻找数组的中心下标
solution:
左求和*2+中心索引值 = 总和
class Solution {
public:
int pivotIndex(vector<int>& nums) {
int sum = 0;
for(auto &x : nums) sum += x; //求出总和
int k = 0;
for(int i = 0;i < nums.size();i++) {
if(i + 1 <= nums.size() && (k * 2 + nums[i] == sum)) return i;
k += nums[i];
}
return -1;
}
};边栏推荐
- Detailed comparison of Hynix emmc5.0 and 5.1 series
- 由于使用flash存放参数时,擦除掉了flash的代码区导致进入硬件错误中断
- Just do it with your hands 7 - * project construction details 2 - hook configuration
- [matlab] matlab simulates digital baseband transmission system - digital baseband transmission system
- 记几个智能手表相关芯片 蓝牙芯片 低功耗
- 如何构建属于自己的知识引擎?社群开放申请
- [wechat applet] template and configuration (wxml, wxss, global and page configuration, network data request)
- Exercise bubble sort
- The data mark is a piece of fat meat, and it is not only China Manfu technology that focuses on this meat
- 中科磐云—D模块解析以及评分标准
猜你喜欢
![[technology development -25]: integration technology of radio and television network, Internet, telecommunication network and power grid](/img/87/e0469e280365ed0261e2b551ebd888.png)
[technology development -25]: integration technology of radio and television network, Internet, telecommunication network and power grid

Topological sorting and graphical display of critical path

海力士EMMC5.0及5.1系列对比详解

How to build your own knowledge engine? Community open application

Just do it with your hands 7 - * project construction details 2 - hook configuration

中科磐云—2022广东木马信息获取解析

【QT】定时器

光模塊字母含義及參數簡稱大全

中職組網絡安全—內存取證

Flutter ‘/usr/lib/libswiftCore. dylib‘ (no such file)
随机推荐
[matlab] matlab simulates digital baseband transmission system eye diagram of bipolar baseband signal (cosine roll off forming pulse)
2022广东省赛——编码信息获取 解析flag
Li Kou's 300th weekly match
2022 question bank and answers for safety management personnel of hazardous chemical business units
JS string splicing enhancement
[matlab] general function of communication signal modulation - generation of narrow-band Gaussian white noise
[MySQL practice of massive data with high concurrency, high performance and high availability -8] - transaction isolation mechanism of InnoDB
中职组网络安全—内存取证
Letter meaning and parameter abbreviation of optical module Daquan
Just do it with your hands 7 - * project construction details 2 - hook configuration
Customize a pager needed in your project
LM小型可编程控制器软件(基于CoDeSys)笔记二十二:错误4268/4052
Several smart watch related chips Bluetooth chip low power consumption
小程序毕业设计---美食、菜谱小程序
2022g2 power station boiler stoker special operation certificate examination question bank and answers
[matlab] matlab simulation modulation system - DSB system
2022G2电站锅炉司炉特种作业证考试题库及答案
Yyds dry goods inventory TCP & UDP
[matlab] matlab simulates digital baseband transmission system eye diagram of bipolar baseband signal (class I part response waveform)
[matlab] matlab simulates digital bandpass transmission systems - QPSK and OQPSK systems