FastPrepPartition Into K Subarrays With Sum at Least X
Problems/Partition Into K Subarrays With Sum at Least X

Partition Into K Subarrays With Sum at Least X

Google logoGoogle● MediumNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: An early-career Google virtual onsite report asks whether a list of positive integers can be split into k ordered contiguous sublists whose smallest sum is at least x. It then asks how negative values change the solution. Our version is the signed-integer follow-up, and we added the function signature and the input limits. Our version is about 92% the same as the reported question.

You are given an integer array nums and integers k and x.

Can you split the entire array into exactly k nonempty consecutive parts, keeping the original order, so that each part has a sum of at least x?

Return true if such a partition exists. Otherwise, return false.

Implement canPartitionWithMinimumSum(nums, k, x).

Function

canPartitionWithMinimumSum(nums: int[], k: int, x: int) → boolean

Examples

Example 1

nums = [3,1,4,2,2]k = 3x = 4return = true

One valid partition is [3,1] | [4] | [2,2]. All three subarray sums equal 4.

Example 2

nums = [100,1,1]k = 2x = 50return = false

The only cut positions produce sums 100 and 2, or 101 and 1. In both cases, one subarray sum is below 50.

Example 3

nums = [10,-5,5]k = 2x = 5return = true

The partition [10,-5] | [5] has subarray sums 5 and 5. Cutting immediately after 10 would fail, which is why a positive-only greedy rule does not handle negative values.

Constraints

  • 1 <= nums.length <= 2000.
  • 1 <= k <= nums.length.
  • -10^9 <= nums[i] <= 10^9.
  • 1 <= x <= 10^9.
  • Subarray sums may exceed 32-bit integer range.

More Google Onsite Interview questions

  • 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
  • Route Pattern MatcherPHONE SCREEN · ONSITE 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

  • Maximum Subarray SumCapital One · PHONE SCREEN · ONSITE INTERVIEWCapital One interview questions
  • Maximum Game Score with Fixed Forward JumpsStripe · OAStripe interview questions
  • Best Improvement Period of at Least K IntervalsAmazon · PHONE SCREEN
  • Minimum Variance Sum SplitAirbnb · PHONE SCREENAirbnb interview questions
  • Largest All-One Square Area and CountNVIDIA · PHONE SCREENNVIDIA interview questions
  • Maximum Apples from Two Disjoint Fixed-Length SegmentsMarshall Wace · OAMarshall Wace interview questions
  • Maximum Non-Decreasing Array LengthVisa · OAVisa interview questions
  • Maximize CollaborationTikTok · OATikTok interview questions
  • Maximum Sum RectangleDeloitte · OADeloitte interview questions
  • Subarray Sum Equals KServiceNow · ONSITE INTERVIEWServiceNow interview questions

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
  • Google Experienced SWE First Round and Onsite: 1 Experience
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public boolean canPartitionWithMinimumSum(int[] nums, int k, int x) {
      // write your code here
    }
}
Checking account…