Notes

Personal notes on various topics

View on GitHub

Minimum Size Subarray Sum

Given an array of positive integers nums and a positive integer target, find the minimal length of a contiguous subarray of which the sum is greater than or equal to target. If no such subarray exists, return 0.

Examples

Constraints

Follow-up
If you have solved the problem with an O(n) solution, try implementing an O(n log n) solution.

Code Template

class Solution:
    def minSubArrayLen(self, target: int, nums: List[int]) -> int:
        # Your code here
        pass

Solutions

Back to Problem List Back to Categories