Grokking 75: Top Coding Interview Questions
Ask Author
Back to course home

0% completed

Vote For New Content
Minimum Size Subarray Sum (medium)
On this page

Problem Statement

Given a nums array containing positive integers and a positive integer target, return the minimum length of a subarray having the sum of elements greater than or equal to target. If there is no such subarray, return 0 instead.

Examples

Example 1:

  • Input: target = 15, nums = [1, 2, 3, 4, 5, 6, 7, 8]
  • Expected Output: 2
  • Justification: The subarray [7, 8] has a sum of 15, which is equal to target and is the smallest possible subarray.

Example 2:

  • Input: target = 11, nums = [2, 1, 5, 2, 8]

.....

.....

.....

Like the course? Get enrolled and start learning!

On this page