FastPrepIndex With Equal Sums on Both Sides
Problems/Index With Equal Sums on Both Sides

Index With Equal Sums on Both Sides

Bloomberg LP logoBloomberg LP● EasyNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A new-grad report from a Bloomberg loop says the screening round paired a design question with one coding task, named "magic index" in the report: pick a position that splits a list into two equal sides. It gives no example, limits or rules beyond that one line.

Everything else here is our practice choice. The two sides are compared by their sums, and the value at the chosen position belongs to neither side. An empty side counts as 0. If several positions work, return the smallest; if none works, return -1. A list has 1 to 10,000 integers from -10,000 to 10,000.

The judged task matches the report at about 80%.

You are given an integer array nums. Find an index i where the two sides of the array balance.

The left side is every value before index i, and the right side is every value after it. The value nums[i] itself is on neither side. Index i balances when the sum of the left side equals the sum of the right side. A side with no values has sum 0, so index 0 and the last index can also balance.

Return the smallest index that balances. If no index balances, return -1.

Function

pivotIndex(nums: int[]) → int

Examples

Example 1

nums = [2,7,4,3,6]return = 2

Check each index. The value at the index itself is not on either side.

  • Index 0: left sum 0, right sum 7 + 4 + 3 + 6 = 20.
  • Index 1: left sum 2, right sum 4 + 3 + 6 = 13.
  • Index 2: left sum 2 + 7 = 9, right sum 3 + 6 = 9. They are equal, so return 2.

Example 2

nums = [5,-5,9]return = 2

At index 2 the left sum is 5 + (-5) = 0. Nothing is to the right, so the right sum is 0 too. Indexes 0 and 1 do not work (0 vs 4, and 5 vs 9), so return 2.

Example 3

nums = [4,1,2]return = -1

The pairs of side sums are 0 vs 3, 4 vs 2 and 5 vs 0. None are equal, so return -1.

Example 4

nums = [3,0,0,3]return = 1

Index 1 works (3 vs 0 + 3) and index 2 works too (3 + 0 vs 3). Return the smaller one, 1.

Constraints

  • 1 <= nums.length <= 10000
  • -10000 <= nums[i] <= 10000

More Bloomberg LP Phone Screen questions

  • N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Fewest Coins CombinationPHONE SCREEN · Seen Nov 2026
  • Recommend Films from Viewers Who Watched Everything You DidPHONE SCREEN · Seen Nov 2026
  • Track New Values in Sorted OrderPHONE SCREEN · Seen Nov 2026
  • Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Sparse Vector and Matrix OperationsPHONE SCREEN · Seen Oct 2026
  • Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026

Similar questions at other companies

  • Wallet Balance on a Selected DayBharatPe · PHONE SCREEN
  • Range Sum Queries With Prefix SumsAdobe · PHONE SCREENAdobe interview questions
  • Parking-Lot Occupancy TimelineGoogle · PHONE SCREENGoogle interview questions
  • Calculate Server Shutdown PenaltyStripe · PHONE SCREEN · ONSITE INTERVIEWStripe interview questions
  • Find an Equal-Sum SplitMeta · PHONE SCREENMeta interview questions
  • Peak Chat Load Across AgentsCresta · PHONE SCREENCresta interview questions
  • Trapping Rain WaterGoldman Sachs · PHONE SCREENGoldman Sachs interview questions
  • Count Non-Overlapping Pairs of Rectangles That Sum to KWisdomAI · PHONE SCREEN
  • Best Improvement Period of at Least K IntervalsAmazon · PHONE SCREEN
  • Majority Labels over Audio IntervalsNooks · PHONE SCREEN

Bloomberg LP interview experiences

  • Bloomberg SWE Phone Screen and Onsite: 1 Experience
  • Bloomberg SWE Phone Screens with Two Teams: 1 Experience
  • Bloomberg AI Interview, Hiring Level Not Reported: 2 Experiences
  • Bloomberg Experienced SWE AI Coding Interviews: 2 Experiences
  • Bloomberg New Grad AI-Assisted Coding Rounds: 3 Experiences
  • Bloomberg New Grad SWE AI-Assisted Coding Rounds: 1 Experience
All Bloomberg LP interview questionsSee Bloomberg LP hiring insights
Saved
class Solution {
    public int pivotIndex(int[] nums) {
        // Write your code here.
    }
}
Checking account…