寻找数组的中心索引 #9
Replies: 2 comments 1 reply
-
test |
Beta Was this translation helpful? Give feedback.
0 replies
-
666 |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
寻找数组的中心索引
来源:力扣 - LeetCode 题目描述给你一个整数数组 nums ,请计算数组的中心下标 。 数组中心下标是数组的一个下标,其左侧所有元素相加的和等于右侧所有元素相加的和。 如果中心下标位于数组最左端,那么左侧数之和视为 0 ,因为在下标的左侧不存在元素。这一点对于中心下标位于数组最右端同样适用。 如果数组有多个中心下标,应该返回 最靠近左边 的那一个。如果数组不存在中心下标,返回 -1
https://blog.caodong.me/posts/%E5%AF%BB%E6%89%BE%E6%95%B0%E7%BB%84%E7%9A%84%E4%B8%AD%E5%BF%83%E7%B4%A2%E5%BC%95
Beta Was this translation helpful? Give feedback.
All reactions