FastPrepBalance Sums by Removing One Element
Problems/Balance Sums by Removing One Element

Balance Sums by Removing One Element

Google logoGoogle● MediumINTERNNEW GRADPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The original post first described finding a pivot somewhere in the shortened array. The original author then corrected that wording in a follow-up: remove index i and compare the sums on the two sides of i's original position. This fix brings back that confirmed version, and it keeps the existing function name and the input limits.

Given an integer array nums, choose exactly one index i and remove nums[i].

Return true if there is a choice of i for which the sum of the elements strictly before i equals the sum of the elements strictly after i:

sum(nums[0 .. i - 1]) = sum(nums[i + 1 .. n - 1])

The equality is checked around the removed element's original position. Do not search for a different pivot in the shortened array.

Function

canCreatePivot(nums: int[]) → boolean

Examples

Example 1

nums = [2,1,3,1,2]return = true

Remove nums[2] = 3. The left sum is 2 + 1 = 3, and the right sum is 1 + 2 = 3.

Example 2

nums = [1,2,3]return = false

No removal position has equal sums on its two original sides.

Example 3

nums = [-5,4,-5]return = true

Remove the middle value 4. Both side sums are -5.

Constraints

  • 1 <= nums.length <= 200000.
  • -1000000000 <= nums[i] <= 1000000000.
  • Use signed 64-bit arithmetic for all sums.

More Google Onsite Interview questions

  • Delete Nodes and Return Forest RootsONSITE INTERVIEW · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • First and Last Target Position in a Mountain ArrayONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • 0/1 Knapsack with Weight and Volume LimitsONSITE INTERVIEW · Seen Nov 2026
  • Batched Subsequence Word MatchesONSITE INTERVIEW · Seen Nov 2026
  • Course Schedule Cycle DetectionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Filesystem Entity Total SizeONSITE INTERVIEW · Seen Nov 2026
  • Longest Subarray Within an Absolute-Difference LimitONSITE INTERVIEW · Seen Nov 2026
  • Reach a Destination Through Scheduled FlightsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Count Subarrays with Equal Even and Odd CountsMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Maximum Sum Desirable SubarrayGroww · PHONE SCREEN
  • Maximum Size Subarray Sum Equals KeBay · PHONE SCREENeBay interview questions
  • Count Subarrays with Sum KMakeMyTrip.com · ONSITE INTERVIEWMakeMyTrip.com interview questions
  • Detect a Contiguous Subarray with Target SumMeta · PHONE SCREENMeta interview questions
  • Count Subarrays With Target SumAmazon · PHONE SCREEN
  • Count Subarrays with Sum KByteDance · PHONE SCREENByteDance interview questions
  • Subarray Sum Equals KApple · PHONE SCREEN · ONSITE INTERVIEWApple interview questions
  • Longest Equal-Zero-One SubarrayMotive · PHONE SCREEN · ONSITE INTERVIEWMotive interview questions
  • Longest Subarray with a Target SumPeopleStrong · ONSITE INTERVIEWPeopleStrong interview questions

Interview reports that mention this question

  • Google SWE and PhD Intern Coding: 14 Experiences (Part 3 of 3)

Google interview experiences

  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
  • Google Experienced SWE First Round and Onsite: 1 Experience
  • Google AI Coding Interview and AI OA: 2 Experiences
  • Google SWE Intern Interview Results Timeline: 13 Experiences
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public boolean canCreatePivot(int[] nums) {
        // Write your code here.
    }
}
Checking account…