From 31da71492ee9edf222be86563503f0d1536a1a44 Mon Sep 17 00:00:00 2001
From: Aashish A S <106067580+aashish1310003@users.noreply.github.com>
Date: Sun, 13 Apr 2025 12:12:09 +0530
Subject: [PATCH 1/7] =?UTF-8?q?Update=20=E2=9C=85=20=20Pattern=2001=20:=20?=
=?UTF-8?q?Sliding=20Window.md?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
"\342\234\205 Pattern 01 : Sliding Window.md" | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git "a/\342\234\205 Pattern 01 : Sliding Window.md" "b/\342\234\205 Pattern 01 : Sliding Window.md"
index fa3083a..a31d5f7 100644
--- "a/\342\234\205 Pattern 01 : Sliding Window.md"
+++ "b/\342\234\205 Pattern 01 : Sliding Window.md"
@@ -1,7 +1,7 @@
# Pattern 1: Sliding Window
In many problems dealing with an array (or a LinkedList), we are asked to find or calculate something among all the contiguous subarrays (or sublists) of a given size. For example, take a look at this problem:
-### Find Averages of Sub Arrays
+### Find Averages of Sub Arrays ✅
https://leetcode.com/problems/maximum-average-subarray-i/
> Given an array, find the average of all contiguous subarrays of size `K` in it.
From f86005b9cd483bd16659310863340d42f3240493 Mon Sep 17 00:00:00 2001
From: Aashish A S <106067580+aashish1310003@users.noreply.github.com>
Date: Mon, 14 Apr 2025 12:51:15 +0530
Subject: [PATCH 2/7] =?UTF-8?q?Update=20=E2=9C=85=20=20Pattern=2001=20:=20?=
=?UTF-8?q?Sliding=20Window.md?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
"\342\234\205 Pattern 01 : Sliding Window.md" | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git "a/\342\234\205 Pattern 01 : Sliding Window.md" "b/\342\234\205 Pattern 01 : Sliding Window.md"
index a31d5f7..6ed29fb 100644
--- "a/\342\234\205 Pattern 01 : Sliding Window.md"
+++ "b/\342\234\205 Pattern 01 : Sliding Window.md"
@@ -206,7 +206,8 @@ smallestSubarrayWithGivenSum([3, 4, 1, 1, 6], 8)//3
- The time complexity of the above algorithm will be `O(N)`. The outer for loop runs for all elements, and the inner while loop processes each element only once; therefore, the time complexity of the algorithm will be `O(N+N)`), which is asymptotically equivalent to `O(N)`.
- The algorithm runs in constant space `O(1)`.
-## Longest Substring with K Distinct Characters (medium)
+## Longest Substring with K Distinct Characters (medium) ✅
+
https://leetcode.com/problems/longest-substring-with-at-most-k-distinct-characters/
>Given a string, find the length of the longest substring in it with no more than `K` distinct characters.
From 5c3a3aad3006d883dfe87332b82991db5c1b7b39 Mon Sep 17 00:00:00 2001
From: Aashish A S <106067580+aashish1310003@users.noreply.github.com>
Date: Mon, 14 Apr 2025 12:57:20 +0530
Subject: [PATCH 3/7] =?UTF-8?q?Update=20=E2=9C=85=20=20Pattern=2001=20:=20?=
=?UTF-8?q?Sliding=20Window.md?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
"\342\234\205 Pattern 01 : Sliding Window.md" | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git "a/\342\234\205 Pattern 01 : Sliding Window.md" "b/\342\234\205 Pattern 01 : Sliding Window.md"
index 6ed29fb..2107a14 100644
--- "a/\342\234\205 Pattern 01 : Sliding Window.md"
+++ "b/\342\234\205 Pattern 01 : Sliding Window.md"
@@ -206,7 +206,7 @@ smallestSubarrayWithGivenSum([3, 4, 1, 1, 6], 8)//3
- The time complexity of the above algorithm will be `O(N)`. The outer for loop runs for all elements, and the inner while loop processes each element only once; therefore, the time complexity of the algorithm will be `O(N+N)`), which is asymptotically equivalent to `O(N)`.
- The algorithm runs in constant space `O(1)`.
-## Longest Substring with K Distinct Characters (medium) ✅
+## Longest Substring with K Distinct Characters (medium) ✅ [https://www.geeksforgeeks.org/problems/longest-k-unique-characters-substring0853/1](Solution)
https://leetcode.com/problems/longest-substring-with-at-most-k-distinct-characters/
From 5585165fcfed6811220a6821ffdb4416255e1d87 Mon Sep 17 00:00:00 2001
From: Aashish A S <106067580+aashish1310003@users.noreply.github.com>
Date: Mon, 14 Apr 2025 12:58:24 +0530
Subject: [PATCH 4/7] =?UTF-8?q?Update=20=E2=9C=85=20=20Pattern=2001=20:=20?=
=?UTF-8?q?Sliding=20Window.md?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
"\342\234\205 Pattern 01 : Sliding Window.md" | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git "a/\342\234\205 Pattern 01 : Sliding Window.md" "b/\342\234\205 Pattern 01 : Sliding Window.md"
index 2107a14..cea2bbc 100644
--- "a/\342\234\205 Pattern 01 : Sliding Window.md"
+++ "b/\342\234\205 Pattern 01 : Sliding Window.md"
@@ -206,7 +206,7 @@ smallestSubarrayWithGivenSum([3, 4, 1, 1, 6], 8)//3
- The time complexity of the above algorithm will be `O(N)`. The outer for loop runs for all elements, and the inner while loop processes each element only once; therefore, the time complexity of the algorithm will be `O(N+N)`), which is asymptotically equivalent to `O(N)`.
- The algorithm runs in constant space `O(1)`.
-## Longest Substring with K Distinct Characters (medium) ✅ [https://www.geeksforgeeks.org/problems/longest-k-unique-characters-substring0853/1](Solution)
+## Longest Substring with K Distinct Characters (medium) ✅ [solution](https://www.geeksforgeeks.org/problems/longest-k-unique-characters-substring0853/1)
https://leetcode.com/problems/longest-substring-with-at-most-k-distinct-characters/
From 7ec8f57ac559f270623c1c0dfd34596843b26bf7 Mon Sep 17 00:00:00 2001
From: Aashish A S <106067580+aashish1310003@users.noreply.github.com>
Date: Tue, 15 Apr 2025 15:28:45 +0530
Subject: [PATCH 5/7] =?UTF-8?q?Update=20=E2=9C=85=20=20Pattern=2001=20:=20?=
=?UTF-8?q?Sliding=20Window.md?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
"\342\234\205 Pattern 01 : Sliding Window.md" | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git "a/\342\234\205 Pattern 01 : Sliding Window.md" "b/\342\234\205 Pattern 01 : Sliding Window.md"
index cea2bbc..5fc1c7a 100644
--- "a/\342\234\205 Pattern 01 : Sliding Window.md"
+++ "b/\342\234\205 Pattern 01 : Sliding Window.md"
@@ -266,7 +266,7 @@ longestSubstringWithKdistinct("cbbebi", 3)//5, The longest substrings with no mo
- The above algorithms time complexity will be `O(N)`, where `N` is the number of characters in the input string. The outer for loop runs for all characters, and the inner while loop processes each character only once; therefore, the time complexity of the algorithm will be `O(N+N)`, which is asymptotically equivalent to `O(N)`
- The algorithms space complexity is `O(K)`, as we will be storing a maximum of `K+1` characters in the HashMap.
-## 🔎 Fruits into Baskets (medium)
+## 🔎 Fruits into Baskets (medium) ✅
https://leetcode.com/problems/fruit-into-baskets/
> Given an array of characters where each character represents a fruit tree, you are given two baskets, and your goal is to put the maximum number of fruits in each basket. The only restriction is that each basket can have only one type of fruit.
From 7e7332e758b0983c9b2e85e4171c02a570eec610 Mon Sep 17 00:00:00 2001
From: Aashish A S <106067580+aashish1310003@users.noreply.github.com>
Date: Tue, 15 Apr 2025 15:29:54 +0530
Subject: [PATCH 6/7] =?UTF-8?q?Update=20=E2=9C=85=20=20Pattern=2001=20:=20?=
=?UTF-8?q?Sliding=20Window.md?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
"\342\234\205 Pattern 01 : Sliding Window.md" | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git "a/\342\234\205 Pattern 01 : Sliding Window.md" "b/\342\234\205 Pattern 01 : Sliding Window.md"
index 5fc1c7a..fddd8df 100644
--- "a/\342\234\205 Pattern 01 : Sliding Window.md"
+++ "b/\342\234\205 Pattern 01 : Sliding Window.md"
@@ -360,7 +360,7 @@ fruitsInBaskets(['A', 'B', 'C', 'B', 'B', 'C'])//5 , We can put 3 'B' in one bas
````
- The above algorithms time complexity will be `O(N)`, where `N` is the number of characters in the input array. The outer `for` loop runs for all characters, and the inner `while` loop processes each character only once; therefore, the time complexity of the algorithm will be `O(N+N)`, which is asymptotically equivalent to `O(N)`.
- The algorithm runs in constant space `O(1)` as there can be a maximum of three types of fruits stored in the frequency map.
-### Longest Substring with at most 2 distinct characters
+### Longest Substring with at most 2 distinct characters ✅
https://leetcode.com/problems/longest-substring-with-at-most-two-distinct-characters/
> Given a string, find the length of the longest substring in it with at most two distinct characters.
From 3978ba91e7cc3b4868b1ec67301fe0013bbb0e31 Mon Sep 17 00:00:00 2001
From: Aashish A S <106067580+aashish1310003@users.noreply.github.com>
Date: Sun, 4 May 2025 14:12:19 +0530
Subject: [PATCH 7/7] =?UTF-8?q?Update=20=E2=9C=85=20=20Pattern=2001=20:=20?=
=?UTF-8?q?Sliding=20Window.md?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
"\342\234\205 Pattern 01 : Sliding Window.md" | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git "a/\342\234\205 Pattern 01 : Sliding Window.md" "b/\342\234\205 Pattern 01 : Sliding Window.md"
index fddd8df..100a54b 100644
--- "a/\342\234\205 Pattern 01 : Sliding Window.md"
+++ "b/\342\234\205 Pattern 01 : Sliding Window.md"
@@ -403,7 +403,7 @@ lengthOfLongestSubstringTwoDistinct('ccaabbb')//5
-## No-repeat Substring (hard)
+## No-repeat Substring (hard) ✅
https://leetcode.com/problems/longest-substring-without-repeating-characters/
> Given a string, find the length of the longest substring, which has no repeating characters.
@@ -451,7 +451,7 @@ nonRepeatSubstring("abccde")//3
- The above algorithms time complexity will be `O(N)`, where `N` is the number of characters in the input string.
- The algorithms space complexity will be `O(K)`, where `K` is the number of distinct characters in the input string. This also means `K<=N`, because in the worst case, the whole string might not have any repeating character, so the entire string will be added to the HashMap. Having said that, since we can expect a fixed set of characters in the input string (e.g., 26 for English letters), we can say that the algorithm runs in fixed space `O(1)`; in this case, we can use a fixed-size array instead of the HashMap.
-## Longest Substring with Same Letters after Replacement (hard)
+## Longest Substring with Same Letters after Replacement (hard) ✅
https://leetcode.com/problems/longest-repeating-character-replacement/
> Given a string with lowercase letters only, if you are allowed to replace no more than `K` letters with any letter, find the length of the longest substring having the same letters after replacement.
@@ -505,7 +505,7 @@ lengthOfLongestSubstring("abccde", 1)//3, Replace the 'b' or 'd' with 'c' to hav
- The above algorithms time complexity will be `O(N)`, where `N` is the number of letters in the input string.
- As we expect only the lower case letters in the input string, we can conclude that the space complexity will be `O(26)` to store each letters frequency in the HashMap, which is asymptotically equal to `O(1)`.
-## Longest Subarray with Ones after Replacement (hard)
+## Longest Subarray with Ones after Replacement (hard) ✅
https://leetcode.com/problems/max-consecutive-ones-iii/
> Given an array containing `0`'s and `1`'s, if you are allowed to replace no more than `K` `0`'s with `1`'s,