FastPrepGold Chain Equal Splits After Removing One Link
Problems/Gold Chain Equal Splits After Removing One Link

Gold Chain Equal Splits After Removing One Link

Google logoGoogle● MediumNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report asks whether you can remove one weighted link, reconnect without reordering, and make a contiguous split with equal weight. A follow-up asks for every way to do it. The original author confirms the [1,5,3,4] and [1,3,4] examples, that reconnecting is the same as deleting one array element, and a target of O(n). The report does not give input limits or an output format. Here we use positive weights and rows of [removedIndex, leftCount]. Our version is about 95% the same as the reported question.

A gold chain has n links in their current order, and weights[i] is the positive weight of link i.

Remove exactly one link, reconnect the remaining links without reordering them, and split the reconnected chain into two nonempty pieces of consecutive links. A method is valid when the two pieces have equal total weight.

Return every valid method as [removedIndex, leftCount], where removedIndex is the original index of the removed link and leftCount is the number of links in the left piece after removal. Order the rows by increasing leftCount, then by increasing removedIndex. Return an empty array when no method works.

The original yes-or-no question is true exactly when the returned array is nonempty.

Function

equalGoldChainSplits(weights: int[]) → int[][]

Examples

Example 1

weights = [1,5,3,4]return = [[1,2]]

Remove link 1, leaving [1,3,4]. The first two remaining links weigh 4, equal to the final link, so [1,2] is valid.

Example 2

weights = [1,3,4]return = []

Removing any one link leaves two links with different weights, so no equal split exists.

Example 3

weights = [1,1,1]return = [[0,1],[1,1],[2,1]]

Removing any link leaves [1,1], whose only split has one link on each side. Rows share leftCount = 1 and are ordered by removed index.

Constraints

  • 3 <= weights.length <= 100000.
  • 1 <= weights[i] <= 1000000000.
  • The answer contains at most 2 * weights.length rows.

More Google Onsite Interview questions

  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Distinct Subset SumsONSITE INTERVIEW · Seen Nov 2026
  • Playlist With No Same Artist in a RowONSITE INTERVIEW · Seen Nov 2026
  • 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

Similar questions at other companies

  • Subarray Sum Equals KServiceNow · ONSITE INTERVIEWServiceNow interview questions
  • Count Subarrays with Equal Even and Odd CountsMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Count Subarrays with Sum KMakeMyTrip.com · ONSITE INTERVIEWMakeMyTrip.com interview questions
  • Subarray Sum Equals KApple · PHONE SCREEN · ONSITE INTERVIEWApple interview questions
  • Longest Equal-Zero-One SubarrayMotive · PHONE SCREEN · ONSITE INTERVIEWMotive interview questions
  • Find and Measure the Longest Target-Sum SubarrayMeta · ONSITE INTERVIEWMeta interview questions
  • Longest Subarray with a Target SumPeopleStrong · ONSITE INTERVIEWPeopleStrong interview questions
  • Count Subarrays Whose Sum Is KExpedia · ONSITE INTERVIEWExpedia interview questions
  • Number of Submatrices That Sum to TargetWhatNot · ONSITE INTERVIEWWhatNot interview questions
  • Maximum Sum Desirable SubarrayGroww · PHONE SCREEN

Interview reports that mention this question

  • Google New Grad Mountain View Onsite: 1 Experience

Google interview experiences

  • Google interviews · November 2026
  • Google Software Engineer Onsite Questions: 10 Experiences
  • Google OA: What It Tests (2026)
  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public int[][] equalGoldChainSplits(int[] weights) {
        // write your code here
    }
}
Checking account…