leetcode:每日LeetCode记录

时间:2021-05-01 22:46:15
【文件属性】:
文件名称:leetcode:每日LeetCode记录
文件大小:251KB
文件格式:ZIP
更新时间:2021-05-01 22:46:15
javascript algorithm algorithms leetcode leetcode-records LeetCode记录 大批 先锋和法 给定一个整数数组nums ,编写一个返回该数组“ pivot”索引的方法。 我们将枢轴索引定义为索引,其中索引左侧的数字总和等于索引右侧的数字总和。 如果不存在这样的索引,则应返回-1。 如果有多个枢轴索引,则应返回最左侧的枢轴索引。 范例1: Input: nums = [1, 7, 3, 6, 5, 6] Output: 3 Explanation: The sum of the numbers to the left of index 3 (nums[3] = 6) is equal to the sum of numbers to the right of index 3. Also, 3 is the first index where this occurs. 范例2: Input: nums = [1, 2, 3] Out

网友评论