摘要:
应用及优点: 1.可用于解决数组或者字符串的子元素问题。 2.用单循环代替了嵌套循环问题,时间复杂度低。 3.用双指针维护动态窗口。 相关算法题: Longest Substring Without Repeating Characters无重复最长子串 Find All Anagrams in a 阅读全文
摘要:
class Solution { public int subarraySum(int[] nums, int k) { HashMap<Integer,Integer> h=new HashMap<>(); int sum=0; int count=0; h.put(0,1); for(int i=0;i<nums.length;i++){ sum+=nums[i]; if(h.contains 阅读全文