Tap here to switch tabs
Problem
Submissions

Problem: Find the Middle Index in Array

med
30 min
Try to solve the Find the Middle Index in Array problem.

Statement

Given a 00 indexed integer array nums, find the leftmost middleIndex such that the sum of the elements strictly to the left of middleIndex equals the sum of the elements strictly to the right of middleIndex.

If middleIndex is 00, the left sum is considered to be 00. Similarly, if middleIndex is equal to nums.length −1- 1, the right sum is considered to be 00.

Return the leftmost middleIndex that satisfies these conditions, or −1-1 if no such index exists.

Note: This question is identical to Pivot Index.

Constraints:

  • 1≤1 \le nums.length ≤100\le 100

  • −1000≤-1000 \le nums[i] ≤1000\le 1000

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find the Middle Index in Array

med
30 min
Try to solve the Find the Middle Index in Array problem.

Statement

Given a 00 indexed integer array nums, find the leftmost middleIndex such that the sum of the elements strictly to the left of middleIndex equals the sum of the elements strictly to the right of middleIndex.

If middleIndex is 00, the left sum is considered to be 00. Similarly, if middleIndex is equal to nums.length −1- 1, the right sum is considered to be 00.

Return the leftmost middleIndex that satisfies these conditions, or −1-1 if no such index exists.

Note: This question is identical to Pivot Index.

Constraints:

  • 1≤1 \le nums.length ≤100\le 100

  • −1000≤-1000 \le nums[i] ≤1000\le 1000