FastPrepMinimum Size Subarray Sum With Negatives
Problems/Minimum Size Subarray Sum With Negatives

Minimum Size Subarray Sum With Negatives

Tekion logoTekion● HardINTERNONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Tekion intern onsite interview. The report links the base problem with positive numbers and clearly adds negative values in the array. Our version is about 97% the same as the reported variant.

Given an integer array nums, which may contain negative values, and a positive integer k, return the minimum length of a non-empty contiguous subarray whose sum is at least k.

If no such subarray exists, return 0.

Function

minSubArrayLenWithNegatives(nums: int[], k: int) → int

Examples

Example 1

nums = [2,3,1,2,4,3]k = 7return = 2

The subarray [4,3] has sum 7, and no one-element subarray reaches 7.

Example 2

nums = [2,-1,2]k = 3return = 3

Only the complete subarray has sum at least 3.

Example 3

nums = [1,-1,1]k = 4return = 0

No non-empty subarray reaches a sum of 4.

Constraints

  • 1 <= nums.length <= 10^5.
  • 1 <= k <= 10^9.
  • nums may contain positive, zero, and negative integers.

More Tekion interview questions

  • Largest Rectangle in HistogramONSITE INTERVIEW · Seen Sep 2026
  • Next Greater Element to the RightONSITE INTERVIEW · Seen Sep 2026
  • Koko Eating BananasONSITE INTERVIEW · Seen Sep 2026
  • Maximum Sum of a Unique-Element SubarrayONSITE INTERVIEW · Seen Jul 2026
  • Number of IslandsONSITE INTERVIEW · Seen Jul 2026
  • Set Matrix ZeroesONSITE INTERVIEW · Seen Jul 2026
  • Peak Resource Usage Across Weighted IntervalsPHONE SCREEN · Seen Sep 2026
  • Dungeon GamePHONE SCREEN · Seen Sep 2026
  • IPOPHONE SCREEN · Seen Sep 2026
  • Coin Game From The EndsPHONE SCREEN · Seen Sep 2026

Similar questions at other companies

  • Maximum Subarray Sum with Length at Most KOracle · ONSITE INTERVIEWOracle interview questions
  • Shortest Subarray with Sum at Least KApple · ONSITE INTERVIEWApple interview questions
  • Shortest Subarray with Sum at Least KGoldman Sachs · PHONE SCREENGoldman Sachs interview questions
  • Shortest Subarray with Sum at Least KGoogle · PHONE SCREENGoogle interview questions
  • Profit AnalysisVirtu Financial · OAVirtu Financial interview questions
  • Sliding Window MaximumAmazon · ONSITE INTERVIEW
  • Sliding Window MaximumPeopleStrong · ONSITE INTERVIEWPeopleStrong interview questions
  • Sliding Window MaximumBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Round-Robin Iterator over IteratorsBridge · ONSITE INTERVIEWBridge interview questions
  • Count Subarrays with Equal Even and Odd CountsMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
All Tekion interview questionsSee Tekion hiring insights
Saved
class Solution {
    public int minSubArrayLenWithNegatives(int[] nums, int k) {
        // Write your code here.
    }
}
Checking account…