和为K的子数组 暴力 或 hash+前缀

题目:

  和为K的子数组 暴力 或 hash+前缀

 思路:

  1 暴力解决

  2 前缀和 + hash表


(一)代码  暴力

  和为K的子数组 暴力 或 hash+前缀


 (二)代码  前缀和

         和为K的子数组 暴力 或 hash+前缀


    前缀和  

       s[i] = s[i-1] + nums[i]