leecode five hundred and sixtieth title (and the K sub-array)

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:

 

Guess you like

Origin www.cnblogs.com/CJT-blog/p/11301234.html