LeetCode Problem: Minimum Size Subarray Sum

Problem statement:

Given a array of positive integers (nums) and a target, return the minimum length of subarray whose sum is greater than or equal to target

Example:

Input:

[2,3,1,2,4,3]  

Expected output:

7

If you would like to solve the problem on Leetcode, here is the link to the problem: https://leetcode.com/problems/minimum-size-subarray-sum/

Golang Solution:
func minSubArrayLen(target int, nums []int) int {
    
    if len(nums) == 0 {
        return 0
    }

    i, j := 0, 0
    minLen := 99999999999
    tempSum := 0

    for j < len(nums) {        
        tempSum += nums[j]

        for tempSum >= target {
            if minLen > j - i + 1 {
                minLen = j - i + 1
            }
            tempSum -= nums[i]
            i += 1
        }

        j += 1

    }

    if minLen == 99999999999 {
        minLen = 0
    }

    return minLen
}