Tap here to switch tabs
Problem
Submissions

Problem: Find the Smallest Balanced Index

Try to solve the Find the Smallest Balanced Index problem.

Statement

Given an array of positive integers nums, find the smallest balanced index i.

An index i is defined as balanced if the sum of all elements strictly to the left of i is equal to the product of all elements strictly to the right of i.

Return the smallest balanced index i. If no balanced index exists, return −1-1.

Note: The sum of elements to the left of index 00 is considered to be 00, and the product of elements to the right of the last index is considered to be 11.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find the Smallest Balanced Index

Try to solve the Find the Smallest Balanced Index problem.

Statement

Given an array of positive integers nums, find the smallest balanced index i.

An index i is defined as balanced if the sum of all elements strictly to the left of i is equal to the product of all elements strictly to the right of i.

Return the smallest balanced index i. If no balanced index exists, return −1-1.

Note: The sum of elements to the left of index 00 is considered to be 00, and the product of elements to the right of the last index is considered to be 11.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤109\leq 10^9