当前位置:网站首页>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;
}
};边栏推荐
- 空洞卷积、可变形卷积、可变形ROI Pooling
- 拓扑排序和关键路径的图形化显示
- 模拟小根堆
- VB.net 调用FFmpeg简单处理视频(类库——6)
- Risc-v-qemu-virt in FreeRTOS_ Lock mechanism analysis of GCC
- C language simple student management system (including source code)
- What are the reasons for the frequent high CPU of ECS?
- June 2022 summary
- 基于单片机的太阳能杀虫系统
- 2022年T电梯修理操作证考试题库及模拟考试
猜你喜欢

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

2022 question bank and answers for safety management personnel of hazardous chemical business units

【QT】定时器

Zhongke Panyun - module a infrastructure setting and safety reinforcement scoring standard
![[paper summary] zero shot semantic segmentation](/img/78/ee64118d86a7e43ec4d1cb97191fbe.jpg)
[paper summary] zero shot semantic segmentation

SQL injection - injection based on MSSQL (SQL Server)

Principle and practice of common defects in RSA encryption application

ping端口神器psping

Two sides of the evening: tell me about the bloom filter and cuckoo filter? Application scenario? I'm confused..

Flask
随机推荐
Evolution of system architecture: differences and connections between SOA and microservice architecture
c语言经典指针和数组笔试题解析
Integer type of C language
BUU-Real-[PHP]XXE
总线的基本概念
Li Kou's 300th weekly match
ansys命令
Simulink与Arduino串口通信
Zhongke panyun-2022 Guangdong Trojan horse information acquisition and analysis
Unity is connected to the weather system
How to configure static IP for Kali virtual machine
小程序毕业设计---美食、菜谱小程序
Unity2d -- character moves and turns
Zhongke Panyun - module a infrastructure setting and safety reinforcement scoring standard
2022G2电站锅炉司炉特种作业证考试题库及答案
VB. Net GIF (making and disassembling - optimizing code, class library - 5)
[matlab] matlab simulates digital baseband transmission system eye diagram of bipolar baseband signal (class I part response waveform)
1480. 一维数组的动态和
Error response from daemon: You cannot remove a running container 8d6f0d2850250627cd6c2acb2497002fc3
Principle and practice of common defects in RSA encryption application