当前位置:网站首页>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;
}
};边栏推荐
- Trie number dictionary tree
- Flink1.13 basic SQL syntax (II) join operation
- [matlab] matlab simulation - simulate the AM modulation process of the modulation system
- 拓扑排序和关键路径的图形化显示
- 【QT】制作MyComboBox点击事件
- C # character similarity comparison general class
- Solar insect killing system based on single chip microcomputer
- 2022年R2移动式压力容器充装复训题库及答案
- Customize a pager needed in your project
- Integer type of C language
猜你喜欢

BUU-Crypto-Cipher

Integer type of C language

2022 Guangdong provincial competition - code information acquisition and analysis flag

724. 寻找数组的中心下标

How to configure static IP for Kali virtual machine

2022年R2移动式压力容器充装复训题库及答案

云原生架构实战案例及优化解决方案

Build an Internet of things infrared temperature measuring punch in machine with esp32 / rush to work after the Spring Festival? Baa, no matter how hard you work, you must take your temperature first

光模块字母含义及参数简称大全

KMP match string
随机推荐
Zhongke panyun-2022 Guangdong Trojan horse information acquisition and analysis
[matlab] matlab simulates digital bandpass transmission systems - QPSK and OQPSK systems
【兴趣阅读】Adversarial Filtering Modeling on Long-term User Behavior Sequences for Click-Through Rate Pre
SQL performance optimization skills
A summary of the 8544 problem that SolidWorks Standard cannot obtain a license
【雕爷学编程】Arduino动手做(105)---压电陶瓷振动模块
Zhongke Panyun - module a infrastructure setting and safety reinforcement scoring standard
Get the ID of the record just inserted from laravel
Remote desktop client RDP
Exercise bubble sort
c语言经典指针和数组笔试题解析
2022 question bank and answers for safety management personnel of hazardous chemical business units
[matlab] matlab simulation - narrow band Gaussian white noise
企业级日志分析系统ELK(如果事与愿违那一定另有安排)
[技术发展-25]:广播电视网、互联网、电信网、电网四网融合技术
Write a complete answer applet (including single choice questions, judgment questions and multiple topics) (III) single choice questions, judgment questions, and the first question display
[matlab] communication signal modulation general function interpolation function
Just do it with your hands 7 - * project construction details 2 - hook configuration
[matlab] matlab simulation - low pass Gaussian white noise
Notepad++--显示相关的配置