class Solution { public : int subarraySum (Vector < int > the nums &, int K) { int CUR = 0 , RES = 0 ; unordered_map < int , int > UM; // Note that a prefix and more than 0 to prevent missing prefix where exactly equal to k and an array UM [ 0 ] = . 1 ; for ( int NUM: the nums) { CUR + = NUM; RES + = um.find (CUR - k) == um.end ()? 0 : um [cur -k]; ++ um [why]; } Return res; } };
analysis: