当前位置:网站首页>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;
}
};边栏推荐
- Ping port artifact psping
- Notepad++ -- display related configurations
- Exercise bubble sort
- Programming example of stm32f1 and stm32subeide -74hc595 drives 4-bit 7-segment nixie tube
- 【雕爷学编程】Arduino动手做(105)---压电陶瓷振动模块
- 【QT】制作MyComboBox点击事件
- What is MQ?
- 2022年R2移动式压力容器充装复训题库及答案
- Nodejs learning document
- LM小型可编程控制器软件(基于CoDeSys)笔记二十二:错误4268/4052
猜你喜欢

A summary of the 8544 problem that SolidWorks Standard cannot obtain a license

RSA加密应用常见缺陷的原理与实践
![[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

【QT】定时器

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

2022g2 power station boiler stoker special operation certificate examination question bank and answers

2022G2电站锅炉司炉特种作业证考试题库及答案

Introduction To AMBA 简单理解

补某视频网站的js,进行视频解密
![BUU-Real-[PHP]XXE](/img/97/b7139270145e6aa6a4f5d1067e2527.jpg)
BUU-Real-[PHP]XXE
随机推荐
Supplement the JS of a video website to decrypt the video
简易零钱通
Letter meaning and parameter abbreviation of optical module Daquan
Solar insect killing system based on single chip microcomputer
Leetcode 184 Employees with the highest wages in the Department (July 3, 2022)
[matlab] general function of communication signal modulation - generation of narrow-band Gaussian white noise
JS string splicing enhancement
C language simple student management system (including source code)
Just do it with your hands 7 - * project construction details 2 - hook configuration
2022年R2移动式压力容器充装复训题库及答案
1480. 一维数组的动态和
Graduation design of small programs -- small programs of food and recipes
2022 Guangdong provincial competition - code information acquisition and analysis flag
TCP state transition diagram
Character types of C language
c语言经典指针和数组笔试题解析
SQL performance optimization skills
ETCD数据库源码分析——初始化总览
Viewing and using binary log of MySQL
2022危险化学品经营单位安全管理人员上岗证题库及答案