This question evaluates understanding of prefix-sum concepts, use of linear-time data structures, and competence in handling negative numbers and edge cases such as zero targets and empty prefixes.

Given an integer array nums and an integer target T, return the number of contiguous subarrays whose sum equals T. Provide an algorithm that runs in linear time using appropriate data structures, and explain how it handles negative numbers and edge cases (e.g., T = 0, empty prefix). Analyze time and space complexity.