This question evaluates a candidate's competence in array-based algorithm design, handling of negative values and contiguous subarray sums, and rigorous time and space complexity analysis.
Given an integer array nums (values may be negative) and an integer T, return the length of the shortest non-empty contiguous subarray whose sum is at least T; return -1 if no such subarray exists. Optimize for n up to 200,000. Explain your approach, prove its correctness, analyze time and space complexity, and implement an O(n) solution.