Optimized Code: class Solution { public int lengthOfLongestSubstring(String s) { int res = 0; int len = s.length(); int l = 0; Map<Character, Integer> map = new HashMap<>(); for (int r = 0; r < len; ++r) { char c = s.charAt(r); if (map.containsKey(c) && map.get...
LeetCode 76 - 最小覆盖子串(Minimum Window Substring) LeetCode 209 - 长度最小的子数组(Minimum Size Subarray Sum) LeetCode 424 - 替换后的最长重复字符(Longest Repeating Character Replacement) LeetCode 438 - 找到字符串中所有字母异位词(Find All Anagrams in a String) LeetCode 567 - 字符串的排列...
[leetcode] Sliding Window algorithm 整理 使用滑动窗口法来解决substring问题的模板如下: 1publicclassSolution {2publicList<Integer>slidingWindowTemplateByHarryChaoyangHe(String s, String t) {3//init a collection or int value to save the result according the question.4List<Integer> result =newLinkedLis...
Find All Anagrams in a String: https://leetcode.com/problems/find-all-anagrams-in-a-string/description/ Minimum Window Substring: https://leetcode.com/problems/minimum-window-substring/description/ Longest Substring Without Repeating Characters: https://leetcode.com/problems/longest-substring-without-...
[LEETCODE]#3 Longest Substring Without Repeating Characters 最长不重复的子串长度, Sliding Window, 滑动窗口 https://leetcode.com/problems/longest-substring-without-repeating-characters/ Given a string, find the length of thelongest substringwithout repeating characters....
滑动窗口算法精讲(Sliding Window Algorithm) 简介 步骤及算法模板 模板1 模板2 leetcode例题讲解 入门级 209. 长度最小的子数组 思路: 代码实现 219. 存在重复元素 II 思路 代码实现 220. 存在重复元素 III 思路 代码实现 进阶级 395. 至少有 K 个重复字符的最长子串 思路 代码实现 经典题目 438. 找到字符...
LeetCode html c++ 239 Sliding Window Maximum 滑动窗口最大值 给定一个数组 nums,有一个大小为 k 的滑动窗口从数组的最左侧移动到数组的最右侧。你只可以看到在滑动窗口 k 内的数字。滑动窗口每次只向右移动一位。例如,给定 nums = [1,3,-1,-3,5,3,6,7],和 k = 3 。窗口位置 最大值 [1 3 ...
repeated.add(s.substring(i, i + 10)); } } return new ArrayList<String>(repeated); } } Non-fixed Size Sliding-Window 3.find all anagrams of shortString in longString Given a string s and a non-empty string p, find all the start indices of p's anagrams in s.Strings consists of ...
1456-maximum-number-of-vowels-in-a-substring-of-given-length.cpp 1461-check-if-a-string-contains-all-binary-codes-of-size-k.cpp 1466-reorder-routes-to-make-all-paths-lead-to-the-city-zero.cpp 1498-number-of-subsequences-that-satisfy-the-given-sum-condition.cpp 1512-number-of-good-pairs....
Dipak-8/DSA-SlidingWindowmain 1 Branch0 Tags Code Folders and files Latest commit Cannot retrieve latest commit at this time. History20 Commits 0003-longest-substring-without-repeating-characters Time: 2 ms (98.65%), Space: 43.6 MB (90.8%) - LeetHub Mar 1, 2025 0424-longest-repeating-...