sliding windows
Belle唯唯
这个作者很懒,什么都没留下…
展开
-
[leetcode] 76. Minimum Window Substring
class Solution { public String minWindow(String s, String t) { int[] map = new int[128]; for(char c:t.toCharArray()){ map[c]++; } int start = 0...原创 2019-07-30 00:38:34 · 76 阅读 · 0 评论 -
[leetcode] 438. Find All Anagrams in a String
class Solution { public int minSubArrayLen(int s, int[] nums) { int start = 0; int end = 0; int total = 0; int count = Integer.MAX_VALUE; while(end < num...原创 2019-08-03 00:49:01 · 73 阅读 · 0 评论 -
[leetcode] 209. Minimum Size Subarray Sum
sliding windowsclass Solution { public int minSubArrayLen(int s, int[] nums) { int start = 0; int end = 0; int total = 0; int count = Integer.MAX_VALUE; wh...原创 2019-08-03 00:52:41 · 66 阅读 · 0 评论 -
[leetcode]30. Substring with Concatenation of All Words
class Solution { public List<Integer> findSubstring(String s, String[] words) { List<Integer> res = new ArrayList<Integer>(); if(s == null || s.length() == 0|| wo...原创 2019-08-07 17:02:29 · 75 阅读 · 0 评论 -
[leetcode]3. Longest Substring Without Repeating Characters
class Solution { public int lengthOfLongestSubstring(String s) { int [] map = new int[128]; int len = Integer.MIN_VALUE; int start = 0; int end = 0; while(e...原创 2019-08-07 17:07:14 · 78 阅读 · 0 评论 -
Leetcode 159. Longest Substring with At Most Two Distinct Characters
Longest Substring with At Most K Distinct Characters 把count初始设为K就可以 public int lengthOfLongestSubstringTwoDistinct(String s) { Map<Character, Integer> map = new HashMap<>();...原创 2019-08-07 18:21:12 · 84 阅读 · 0 评论 -
[leetcode]697. Degree of an Array
class Solution { public int findShortestSubArray(int[] nums) { HashMap<Integer, Integer> map = new HashMap<>(); int freq = 0, count = 0; int left = 0, right = 0...原创 2019-09-16 12:57:46 · 86 阅读 · 0 评论