当前位置:网站首页>724. Find the central subscript of the array
724. Find the central subscript of the array
2022-07-04 05:28:00 【anieoo】
Original link :724. Find the central subscript of the array
solution:
Left summation *2+ Central index value = The sum of the
class Solution {
public:
int pivotIndex(vector<int>& nums) {
int sum = 0;
for(auto &x : nums) sum += x; // Find the sum
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;
}
};
边栏推荐
- 十二. golang其他
- [matlab] general function of communication signal modulation inverse Fourier transform
- Notepad++ -- display related configurations
- Introduction To AMBA 简单理解
- VB.net 调用FFmpeg简单处理视频(类库——6)
- 2022 Guangdong provincial competition - code information acquisition and analysis flag
- Enterprise level log analysis system elk (if things backfire, there must be other arrangements)
- Just do it with your hands 7 - * project construction details 2 - hook configuration
- Supplement the JS of a video website to decrypt the video
- [technology development -25]: integration technology of radio and television network, Internet, telecommunication network and power grid
猜你喜欢
Integer type of C language
【QT】制作MyComboBox点击事件
C language simple student management system (including source code)
[paper summary] zero shot semantic segmentation
LM小型可编程控制器软件(基于CoDeSys)笔记二十二:错误4268/4052
TCP状态转换图
Electronic components mall and data manual download website summary
2022年T电梯修理操作证考试题库及模拟考试
Topological sorting and graphical display of critical path
BUU-Pwn-test_ your_ nc
随机推荐
Notepad++--显示相关的配置
[matlab] matlab simulates digital bandpass transmission systems - QPSK and OQPSK systems
Unity2d -- character moves and turns
光模块字母含义及参数简称大全
National vocational college skills competition (secondary vocational group) network security competition questions - Analysis
[matlab] matlab simulation of modulation system - power spectrum and coherent demodulation of AM modulated signal
【QT】制作MyComboBox点击事件
【兴趣阅读】Adversarial Filtering Modeling on Long-term User Behavior Sequences for Click-Through Rate Pre
2022 question bank and answers for safety management personnel of hazardous chemical business units
[matlab] general function of communication signal modulation - generation of narrow-band Gaussian white noise
Li Kou's 300th weekly match
LM small programmable controller software (based on CoDeSys) note XXI: error 3703
What is MQ?
Unity2D--人物移动并转身
Zkevm (12) state proof of appliedzkp
With the advent of the IP era, how can E-sports hotels take advantage of the "east wind" of games?
(4) Canal multi instance use
2022 Guangdong provincial competition - code information acquisition and analysis flag
[high concurrency, high performance and high availability of massive data MySQL practice-7] - memory data drop disk
Ping port artifact psping