question_slug
stringlengths
3
77
title
stringlengths
1
183
slug
stringlengths
12
45
summary
stringlengths
1
160
author
stringlengths
2
30
certification
stringclasses
2 values
created_at
stringdate
2013-10-25 17:32:12
2025-04-12 09:38:24
updated_at
stringdate
2013-10-25 17:32:12
2025-04-12 09:38:24
hit_count
int64
0
10.6M
has_video
bool
2 classes
content
stringlengths
4
576k
upvotes
int64
0
11.5k
downvotes
int64
0
358
tags
stringlengths
2
193
comments
int64
0
2.56k
minimum-window-substring
✅☑Beats 97% Users || [C++/Java/Python/JavaScript] || EXPLAINED🔥
beats-97-users-cjavapythonjavascript-exp-g9af
PLEASE UPVOTE IF IT HELPED\n\n---\n\n\n---\n\n\n# Approaches\n(Also explained in the code)\n\n1. Problem Objective:\n\n - The goal is to find the minimum win
MarkSPhilip31
NORMAL
2024-02-04T00:35:17.748122+00:00
2024-02-04T00:35:17.748153+00:00
33,043
false
# PLEASE UPVOTE IF IT HELPED\n\n---\n![Screenshot 2024-02-04 060439.png](https://assets.leetcode.com/users/images/4961d82d-008a-4631-8fca-dc172a848566_1707006901.7990885.png)\n\n---\n\n\n# Approaches\n(Also explained in the code)\n\n1. **Problem Objective:**\n\n - The goal is to find the minimum window in string `s`...
99
1
['Hash Table', 'String', 'Sliding Window', 'Python', 'C++', 'Java', 'Python3', 'JavaScript']
11
minimum-window-substring
[C++] Short Sliding Window Solution with Explanation
c-short-sliding-window-solution-with-exp-dg4w
\n string minWindow(string s, string t) {\n unordered_map<char, int> letters; //unordered map for storing the characters in t that we need to check fo
hunarbatra
NORMAL
2020-01-17T18:09:43.980793+00:00
2020-01-17T18:09:43.980828+00:00
20,266
false
```\n string minWindow(string s, string t) {\n unordered_map<char, int> letters; //unordered map for storing the characters in t that we need to check for in s\n for(auto c : t) letters[c]++; \n int count = 0; //counts number of t\'s letters in current window\n int low = 0, min_length = I...
97
8
['C', 'Sliding Window', 'C++']
15
minimum-window-substring
Python | My advice
python-my-advice-by-dev-josh-wp3w
My advice for solving this problem is to:\n Understand the intuition and what to do at a high level\n Try to implement your own solution WITHOUT copying anyone
dev-josh
NORMAL
2021-02-01T16:21:32.655771+00:00
2021-02-01T16:21:32.655817+00:00
6,294
false
My advice for solving this problem is to:\n* Understand the intuition and what to do at a high level\n* Try to implement your own solution WITHOUT copying anyone elses\n* This is how you will learn\n* You will remember high level concepts, but never line for line code\n\nIntuition:\n* Two pointers, left and right\n* Bo...
76
0
['Python', 'Python3']
12
minimum-window-substring
✅🔥Sliding Window Approach with Explanation - C++/Java/Python
sliding-window-approach-with-explanation-tgop
\n# Intuition\nIn this problem, we need to find the minimum window substring of string s that contains all characters from string t. We can use a sliding window
dhruba-datta
NORMAL
2022-03-28T15:40:08.454696+00:00
2023-12-04T17:10:34.912935+00:00
10,133
false
\n# Intuition\nIn this problem, we need to find the minimum window substring of string `s` that contains all characters from string `t`. We can use a sliding window approach to find the minimum window substring efficiently.\n\n# Approach 01\n1. Create an unordered_map `mp` to store the count of characters in string `t`...
75
1
['Two Pointers', 'Sliding Window', 'Python', 'C++', 'Java', 'Python3']
10
minimum-window-substring
Share my neat java solution
share-my-neat-java-solution-by-tlj77-kd5z
public String minWindow(String S, String T) {\n if(S==null||S.isEmpty()||T==null||T.isEmpty()) return "";\n int i=0, j=0;\n int[] Tmap=new
tlj77
NORMAL
2015-04-22T02:58:02+00:00
2018-09-29T18:05:17.067477+00:00
33,284
false
public String minWindow(String S, String T) {\n if(S==null||S.isEmpty()||T==null||T.isEmpty()) return "";\n int i=0, j=0;\n int[] Tmap=new int[256];\n int[] Smap=new int[256];\n for(int k=0; k< T.length(); k++){\n Tmap[T.charAt(k)]++;\n }\n int found=0;\n ...
72
8
['Java']
11
minimum-window-substring
C++ Solution 68ms explanation
c-solution-68ms-explanation-by-leodicap9-a275
\nWe are going to use a two pointer approach to solve this.\n\nThe idea here is that \n1. We will store the characters of t in a map lets say mapt.\n2. We will
leodicap99
NORMAL
2020-05-07T05:31:08.846128+00:00
2020-05-07T05:31:08.846160+00:00
6,558
false
```\nWe are going to use a two pointer approach to solve this.\n\nThe idea here is that \n1. We will store the characters of t in a map lets say mapt.\n2. We will have two pointers l and r.\n3. Whille we traverse through s we check if the character is found in mapt If so we will store the character into another hash ma...
53
2
['C', 'C++']
10
minimum-window-substring
Simple Java Solution | Sliding Window
simple-java-solution-sliding-window-by-g-f3s1
Kindly upvote, if it helps you!\n```\n public String minWindow(String s, String t) {\n String result = "";\n if(s.length() < t.length())\n
guptap151
NORMAL
2022-01-26T14:28:19.416146+00:00
2022-01-26T18:06:32.834936+00:00
4,902
false
Kindly upvote, if it helps you!\n```\n public String minWindow(String s, String t) {\n String result = "";\n if(s.length() < t.length())\n return result;\n int minWindow = Integer.MAX_VALUE;\n\t\t//We will use two variables \'have\' & \'need\' to keep a track whether the characters \n\t\...
45
1
['Sliding Window', 'Java']
6
minimum-window-substring
Java 4ms bit 97.6%
java-4ms-bit-976-by-huang593-liwd
Basically, there are two pointers for windows sliding. One for exploiting new matched substring, other pointer for expiring previous substring.\n\n public St
huang593
NORMAL
2016-03-30T03:10:24+00:00
2018-10-02T07:05:13.712462+00:00
12,670
false
Basically, there are two pointers for windows sliding. One for exploiting new matched substring, other pointer for expiring previous substring.\n\n public String minWindow(String s, String t) {\n char[] s_array = s.toCharArray();\n char[] t_array = t.toCharArray();\n int[] map = new ...
45
1
[]
4
minimum-window-substring
Sliding Window | Beats 100% | Java | Python | C++ | JS | Go | Rust
sliding-window-beats-100-java-python-c-j-57n6
\n\n### INTUITION\n\n\nWe\u2019re given two strings: s, the large string, and t, the smaller one. Our job is to find the smallest substring of s that contains a
kartikdevsharma_
NORMAL
2024-07-16T10:30:58.919549+00:00
2024-09-11T11:45:39.812527+00:00
7,533
false
\n\n### INTUITION\n\n\nWe\u2019re given two strings: `s`, the large string, and `t`, the smaller one. Our job is to find the **smallest substring** of `s` that contains **all the characters** of `t`, and crucially, we need to consider duplicates. So, if `t` contains two `A`s, then any substring we pick from `s` needs t...
42
0
['Hash Table', 'String', 'Sliding Window', 'C++', 'Java', 'Go', 'Python3', 'Rust', 'JavaScript']
6
minimum-window-substring
C++/JAVA/Python | 🚀 ✅ Sliding Window | ✅ Fully Explained | ✅ Hash Table | ✅ String
cjavapython-sliding-window-fully-explain-ex0g
Intuition:\nThe problem asks to find the minimum window in s that contains all the characters of t. One way to approach this problem is to use a sliding window
devanshupatel
NORMAL
2023-04-14T18:05:53.116403+00:00
2023-04-24T20:23:28.926976+00:00
9,064
false
# Intuition:\nThe problem asks to find the minimum window in s that contains all the characters of t. One way to approach this problem is to use a sliding window technique. We can maintain a window that starts from the beginning of s and moves forward until it contains all the characters of t. Once we have such a windo...
38
0
['Hash Table', 'Sliding Window', 'Python', 'C++', 'Java']
4
minimum-window-substring
c++ || Advance || Sliding window || Fast
c-advance-sliding-window-fast-by-iam_sin-ckn3
Please upvote, your one upvote makes me happy\n\n^____^\n\nHere is the code\n\n\nclass Solution {\npublic:\n\n string minWindow(string str, string pat) {\n
Iam_SinghSunny
NORMAL
2022-10-22T02:50:23.038629+00:00
2023-05-13T03:02:30.827669+00:00
6,945
false
**Please upvote, your one upvote makes me happy**\n\n^____^\n\n**Here is the code**\n\n```\nclass Solution {\npublic:\n\n string minWindow(string str, string pat) {\n \n int len1 = str.length();\n int len2 = pat.length();\n \n const int no_of_chars = 256;\n\n if (len1 < len2) {\n ...
38
1
['C', 'Sliding Window']
3
minimum-window-substring
Simple Python Solution Beats 99% with Detailed Explanation
simple-python-solution-beats-99-with-det-hp5w
The key idea is how you update the tracking variables. There are four essentials variables to track: 1. remaing length of a match 2. The position of previous ma
Brownian_motion
NORMAL
2018-09-15T20:12:14.414718+00:00
2018-10-09T05:15:57.640374+00:00
5,924
false
The key idea is how you update the tracking variables. There are four essentials variables to track: 1. remaing length of a match 2. The position of previous matched first element 3. start_position of returned answer 4. end_position of returned answer. \n\nAnd a dictionary to count the occurrence of characters is usefu...
36
0
[]
2
minimum-window-substring
Java | TC: O(S+T) | SC: O(T) | Space-optimized Sliding Window using Two Pointers
java-tc-ost-sc-ot-space-optimized-slidin-kzl2
java\n/**\n * Space-optimized Sliding Window using Two Pointers\n *\n * Time Complexity: O(S + T)\n *\n * Space Complexity: O(T)\n *\n * S = length of String s.
NarutoBaryonMode
NORMAL
2021-10-01T06:46:46.340722+00:00
2021-10-07T07:56:11.751803+00:00
5,710
false
```java\n/**\n * Space-optimized Sliding Window using Two Pointers\n *\n * Time Complexity: O(S + T)\n *\n * Space Complexity: O(T)\n *\n * S = length of String s. T = length of String t\n */\nclass Solution1 {\n public String minWindow(String s, String t) {\n if (s == null || t == null) {\n throw ...
35
0
['Two Pointers', 'String', 'Sliding Window', 'Java']
3
minimum-window-substring
[Python3] Sliding window O(N+M)
python3-sliding-window-onm-by-yourick-us52
\n# Approach\nThis problem follows the Sliding Window pattern and has a lot of similarities with 567 Permutation in a String with one difference. In this proble
yourick
NORMAL
2023-11-09T17:11:24.818215+00:00
2024-06-27T19:59:25.410276+00:00
2,608
false
\n# Approach\nThis problem follows the Sliding Window pattern and has a lot of similarities with [567 Permutation in a String](https://leetcode.com/problems/permutation-in-string/description/) with one difference. In this problem, we need to find a substring having all characters of the pattern which means that the req...
34
0
['Sliding Window', 'Python', 'Python3']
5
minimum-window-substring
Three O(N) concise implemetation according to leetcode oj discuss
three-on-concise-implemetation-according-ci60
// according to http://leetcode.com/2010/11/finding-minimum-window-in-s-which.html\n // finds the first window that satisfies the constraint\n // then con
shichaotan
NORMAL
2014-12-31T19:13:25+00:00
2014-12-31T19:13:25+00:00
9,563
false
// according to http://leetcode.com/2010/11/finding-minimum-window-in-s-which.html\n // finds the first window that satisfies the constraint\n // then continue maintaining the constraint throughout\n // time complexity O(2N)\n string minWindow(string S, string T) {\n int m = S.size(), n = T.size(...
33
3
[]
2
minimum-window-substring
💡JavaScript Solution w/ Detailed Comments
javascript-solution-w-detailed-comments-jxrzs
javascript\nvar minWindowSlidingWindow = function (s, t) {\n\t// `right` is -1 since every loop, we start by expanding the right boundary\n\t// setting this to
aminick
NORMAL
2019-10-23T02:27:27.114250+00:00
2019-10-23T02:45:04.825380+00:00
6,620
false
``` javascript\nvar minWindowSlidingWindow = function (s, t) {\n\t// `right` is -1 since every loop, we start by expanding the right boundary\n\t// setting this to -1 ensures that we will check the first char on the first time\n let min = "", left = 0, right = -1;\n let map = {};\n\t\n\t// this creates a map for ...
32
0
['JavaScript']
6
minimum-window-substring
Accepted Python solution using hashtable
accepted-python-solution-using-hashtable-0lno
class Solution:\n # @return a string\n def minWindow(self, S, T):\n indices = {}\n for char in T:\n indices[c
xiaoying10101
NORMAL
2015-01-03T04:14:51+00:00
2018-10-26T04:13:16.498421+00:00
9,739
false
class Solution:\n # @return a string\n def minWindow(self, S, T):\n indices = {}\n for char in T:\n indices[char] = []\n miss = list(T)\n start = 0\n end = len(S)\n for i in range(len(S)):\n if S[i] in T:\n...
31
1
[]
4
minimum-window-substring
Python easy to understand
python-easy-to-understand-by-clarketm-pgo7
python\ndef min_window(S: str, T: str) -> str:\n """\n Minimum Window Substring\n\n :param str S:\n :param str T:\n :return str:\n """\n Tc
clarketm
NORMAL
2019-05-05T01:41:24.979072+00:00
2019-05-05T01:41:24.979115+00:00
5,634
false
```python\ndef min_window(S: str, T: str) -> str:\n """\n Minimum Window Substring\n\n :param str S:\n :param str T:\n :return str:\n """\n Tc = Counter(T)\n Sc = Counter()\n\n best_i = -sys.maxsize\n best_j = sys.maxsize\n\n i = 0\n\n for j, char in enumerate(S):\n Sc[char] +...
29
2
['Python']
9
minimum-window-substring
EXPLAINED | Easy to understand code with comments | 3ms
explained-easy-to-understand-code-with-c-s72w
\nclass Solution {\n public String minWindow(String s, String t) {\n int[] count = new int[128];\n\n // Count the characters in t\n for
heisenbergknocks
NORMAL
2020-11-13T08:02:12.571412+00:00
2022-10-25T08:54:03.558312+00:00
2,799
false
```\nclass Solution {\n public String minWindow(String s, String t) {\n int[] count = new int[128];\n\n // Count the characters in t\n for (char ch : t.toCharArray()) count[ch]++;\n\n char[] sourceStr = s.toCharArray();\n String windowString = "";\n int windowLeft = 0, windo...
28
0
['Sliding Window', 'Java']
7
minimum-window-substring
[Python] O(n+m) sliding window, explained
python-onm-sliding-window-explained-by-d-0lmr
The idea of sliding window with 2 pointers: we create counter cnt_t is frequencies how many time s we need to take each symbol, for example for abca we have a:2
dbabichev
NORMAL
2021-08-15T07:52:22.792580+00:00
2021-08-15T07:52:22.792624+00:00
1,442
false
The idea of sliding window with 2 pointers: we create counter `cnt_t` is frequencies how many time s we need to take each symbol, for example for `abca` we have `a:2, b:1, c:1`. We create also `cnt_s` as empty counter, which will keep information about frequencies is current window `[beg, end)` - not that we do not inc...
27
3
['Sliding Window']
3
minimum-window-substring
Super Easy Java Solution or or 100% faster or or Easy to understand
super-easy-java-solution-or-or-100-faste-63p3
Looking for Contribution in Hacktoberfest\n## You are welcomed to contribute in my Repos:-\n# GITHUB LINK --> Yaduttam95\n# All PRs are getting accepted...\n\n#
Yaduttam_Pareek
NORMAL
2022-10-22T01:41:11.734701+00:00
2022-10-22T01:41:11.734744+00:00
2,732
false
# Looking for Contribution in Hacktoberfest\n## You are welcomed to contribute in my Repos:-\n# GITHUB LINK --> [Yaduttam95](https://github.com/Yaduttam95)\n# All PRs are getting accepted...\n\n# Please upvote if Helpful\n```\nclass Solution {\n public String minWindow(String s, String t) {\n \n \n ...
26
0
[]
3
minimum-window-substring
✅ Minimum Window Substring || Using Map w/ Explanation || C++ | Python | Java
minimum-window-substring-using-map-w-exp-4tlx
IDEA\nThe solution is a bit intuitive. We keep expanding the window by moving the right pointer. When the window has all the desired characters, we contract (if
Maango16
NORMAL
2021-08-15T07:58:11.255661+00:00
2021-08-15T07:58:11.255715+00:00
1,917
false
**IDEA**\nThe solution is a bit intuitive. We keep expanding the window by moving the right pointer. When the window has all the desired characters, we contract (if possible) and save the smallest window till now.\n`The answer is the smallest desirable window.`\n\n**EXAMPLE**\nFor eg. `S = "ABAACBAB" T = "ABC"`. Then o...
26
2
[]
9
minimum-window-substring
Sliding Windows||Hash tables->Freq Array||0ms Beats 100%
sliding-windowshash-tables-freq-array0ms-4tes
Intuition\n Describe your first thoughts on how to solve this problem. \n2 kinds of solutions. the main idea is the the sliding windows. but for implementation
anwendeng
NORMAL
2024-02-04T00:46:24.152403+00:00
2024-02-04T06:54:34.247401+00:00
6,243
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n2 kinds of solutions. the main idea is the the sliding windows. but for implementation it needs the info of frequencies of alphabets.\n1 is just using hash tables (map or unordered_map) which is slow & done many months ago.\nOther is usi...
24
0
['Array', 'Hash Table', 'String', 'Bit Manipulation', 'C', 'Sliding Window', 'C++', 'Python3']
8
minimum-window-substring
A visualized first principles approach for better understanding
a-visualized-first-principles-approach-f-xfis
Heres a visualization techinque that might help you get a better idea of the solution. \n\nImagine the strings (henceforth S and T) as a long chain of character
principled_man
NORMAL
2020-07-20T22:58:48.675684+00:00
2020-07-21T16:42:00.081153+00:00
1,141
false
Heres a visualization techinque that might help you get a better idea of the solution. \n\nImagine the strings (henceforth **S** and **T**) as a long chain of characters\n\nFirst we will build a tool that will help us extract information about the target string **T**\n\nWe will extract 2 pieces of info from **T** - \nf...
24
0
['Go']
3
minimum-window-substring
Here is my C++ code with line by line Explanation as comments
here-is-my-c-code-with-line-by-line-expl-7zrv
Please Upvote if you find it useful\n\n\nstring minWindow(string s, string t) {\n \n //This result variable will store the string which we will return\n
yvrjprshr
NORMAL
2021-10-15T07:24:10.931891+00:00
2021-10-15T07:24:10.931931+00:00
3,128
false
Please **Upvote** if you find it useful\n\n```\nstring minWindow(string s, string t) {\n \n //This result variable will store the string which we will return\n string result;\n\n //It will check if any of the two string is empty and return empty string result\n if(s.empty() || t.empty()){\n return...
22
1
['Two Pointers', 'C', 'Sliding Window']
2
minimum-window-substring
✅ One Line Solution
one-line-solution-by-mikposp-ptcs
(Disclaimer: this is not an example to follow in a real project - it is written for fun and training mostly)\n\n# Code #1.1 - Oneliner\nTime complexity: O(n). S
MikPosp
NORMAL
2024-02-04T12:00:50.308006+00:00
2024-02-04T21:23:19.893242+00:00
4,474
false
(Disclaimer: this is not an example to follow in a real project - it is written for fun and training mostly)\n\n# Code #1.1 - Oneliner\nTime complexity: $$O(n)$$. Space complexity: $$O(n)$$.\n```\nclass Solution:\n def minWindow(self, s: str, t: str) -> str:\n return (g:={\'s\':s,\'t\':t,\'a\':0,\'c\':Counter...
21
0
['Hash Table', 'String', 'Sliding Window', 'Counting', 'Python', 'Python3']
10
minimum-window-substring
O(N) JAVA Sliding Window solution with explanation
on-java-sliding-window-solution-with-exp-t6ci
Sliding Window Solution:\n\n 1) Spread the right pointer until it satisfies the requirement \n 2) Shrink the left pointer to get the minimum range \n
cheng_zhang
NORMAL
2015-10-06T03:26:07+00:00
2015-10-06T03:26:07+00:00
6,765
false
**Sliding Window Solution:**\n\n 1) Spread the right pointer until it satisfies the requirement \n 2) Shrink the left pointer to get the minimum range \n 3) Keep the above steps.\n\n**Time complexity = O(2n) = O(n)**\n\nThere're 2 loops: for loop of i, while loop of j. As j only steps forward, never steps bac...
21
4
[]
7
minimum-window-substring
[JavaScript] Simple Sliding Window + Hash Map Solution
javascript-simple-sliding-window-hash-ma-7r40
Time Complexity: O(S + T) where S and T are the respective lengths of strings s and t\nSpace Complexity: O(S + T)\n\nIntuition\n\nThis is actually very similar
ryangdev
NORMAL
2022-07-18T23:48:27.856387+00:00
2022-07-18T23:48:27.856420+00:00
2,733
false
Time Complexity: O(S + T) where S and T are the respective lengths of strings `s` and `t`\nSpace Complexity: O(S + T)\n\n**Intuition**\n\nThis is actually very similar to the [Permutation in String](https://leetcode.com/problems/permutation-in-string/) problem. The difference is that we don\'t match based on string le...
20
0
['Sliding Window', 'JavaScript']
3
minimum-window-substring
Java 100% 2ms | Clean Code w/ Video Explanation
java-100-2ms-clean-code-w-video-explanat-j6g2
Please Upvote if you find the explanation helpful\n\nVideo Explanation\nMinimum Window Substring | YouTube\n\nJava Solution\n\n//2ms\n\nclass Solution {\n pu
sagnik_20
NORMAL
2022-10-22T02:37:39.148739+00:00
2022-10-22T02:37:39.148777+00:00
2,844
false
*Please **Upvote** if you find the explanation helpful*\n\n**Video Explanation**\n[Minimum Window Substring | YouTube](https://www.youtube.com/watch?v=vVSEJuN6BHA&feature=youtu.be)\n\n**Java Solution**\n```\n//2ms\n\nclass Solution {\n public String minWindow(String s, String t) {\n int [] map = new int[128];...
18
1
['Two Pointers', 'Sliding Window', 'Java']
6
minimum-window-substring
easy peasy python [comments] solution
easy-peasy-python-comments-solution-by-l-ieto
\tdef minWindow(self, s: str, t: str) -> str:\n ln_s = len(s)\n ln_t = len(t)\n if ln_s == 0 or ln_t == 0 or ln_t > ln_s:\n retu
lostworld21
NORMAL
2019-09-25T03:17:23.733874+00:00
2019-09-25T03:17:23.733931+00:00
5,029
false
\tdef minWindow(self, s: str, t: str) -> str:\n ln_s = len(s)\n ln_t = len(t)\n if ln_s == 0 or ln_t == 0 or ln_t > ln_s:\n return ""\n dct = {}\n for ch in t:\n dct[ch] = dct.get(ch, 0) + 1\n \n i = j = 0\n minWindow = ln_s + 1\n outp...
18
2
['Sliding Window', 'Python', 'Python3']
2
minimum-window-substring
Java | Beats 100 %
java-beats-100-by-beingbmc12-r2l1
java\nclass Solution {\n public String minWindow(String s, String t) {\n if(s.isEmpty()) return "";\n int[] need = new int[128];\n for(c
beingbmc12
NORMAL
2019-06-09T07:06:31.863273+00:00
2019-06-09T07:06:31.863306+00:00
1,488
false
```java\nclass Solution {\n public String minWindow(String s, String t) {\n if(s.isEmpty()) return "";\n int[] need = new int[128];\n for(char c : t.toCharArray()) need[c]++;\n char[] a = s.toCharArray();\n int r = 0, l = 0, missing = t.length(), i = 0, j = 0;\n while(r < s....
18
0
[]
5
minimum-window-substring
Python, easy to understand, no weird tricks
python-easy-to-understand-no-weird-trick-rww4
\nimport collections\nclass Solution(object):\n def minWindow(self, s, t):\n """\n :type s: str\n :type t: str\n :rtype: str\n
frankli92
NORMAL
2019-03-26T20:56:14.265147+00:00
2019-03-26T20:56:14.265204+00:00
1,086
false
```\nimport collections\nclass Solution(object):\n def minWindow(self, s, t):\n """\n :type s: str\n :type t: str\n :rtype: str\n """\n if len(s) < len(t):\n return ""\n \n hashmap = collections.Counter(t)\n counter = len(t)\n min_windo...
18
0
[]
5
minimum-window-substring
Simple JavaScript solution with comments
simple-javascript-solution-with-comments-ssxg
function minWindow(s, t) {\n var ans = '';\n \n // 1. process hashmap\n var map = {};\n t.split('').forEach(ch => map[ch] = (
linfongi
NORMAL
2016-05-16T03:39:09+00:00
2016-05-16T03:39:09+00:00
4,167
false
function minWindow(s, t) {\n var ans = '';\n \n // 1. process hashmap\n var map = {};\n t.split('').forEach(ch => map[ch] = (map[ch] || 0) + 1);\n var count = Object.keys(map).length;\n \n // 2. traverse s to find boundaries\n // both l & r are inclusiv...
18
0
[]
9
minimum-window-substring
C++ - Easiest Beginner Friendly Sol || Sliding Window
c-easiest-beginner-friendly-sol-sliding-f1qv2
Intuition of this Problem:\nReference - https://leetcode.com/problems/minimum-window-substring/solutions/26808/here-is-a-10-line-template-that-can-solve-most-su
singhabhinash
NORMAL
2023-02-05T09:21:51.345562+00:00
2023-02-05T09:21:51.345594+00:00
2,501
false
# Intuition of this Problem:\nReference - https://leetcode.com/problems/minimum-window-substring/solutions/26808/here-is-a-10-line-template-that-can-solve-most-substring-problems/?orderBy=hot\n<!-- Describe your first thoughts on how to solve this problem. -->\n**NOTE - PLEASE READ APPROACH FIRST THEN SEE THE CODE. YOU...
17
0
['Hash Table', 'String', 'Sliding Window', 'C++']
2
minimum-window-substring
[C++] [Sliding Window] - Simple and easy to understand with explanation | O(n) time complexity
c-sliding-window-simple-and-easy-to-unde-p3vv
Make two frequency count array and store the frequency of t initially\n2. If character match with the characters of t, increment the count variable\n3. if count
morning_coder
NORMAL
2020-10-11T09:21:10.403538+00:00
2020-10-11T09:25:22.376006+00:00
4,905
false
1. Make two frequency count array and store the frequency of t initially\n2. If character match with the characters of t, increment the count variable\n3. if count==length of t (t_len) => we found a window with all characters of t\n4. Minimize the window size by removing extra characters from the start of window (using...
17
2
['C', 'Sliding Window', 'C++']
4
minimum-window-substring
C++ || Sliding Window || Map || String || Easy Explanation || Simple
c-sliding-window-map-string-easy-explana-iewz
Approach \n- Sliding Window Technique!!\n- Map for storing Frequency\n\n# Complexity\n- Time complexity: O(m+n)\n Add your time complexity here, e.g. O(n) \n\n-
yashgaherwar2002
NORMAL
2022-10-22T05:39:05.234493+00:00
2022-10-22T05:39:05.234538+00:00
2,541
false
# Approach \n- Sliding Window Technique!!\n- Map for storing Frequency\n\n# Complexity\n- Time complexity: O(m+n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n\n // Sliding Window ...
15
0
['String', 'Ordered Map', 'Sliding Window', 'C++']
3
minimum-window-substring
[Python] O(N) and O(T) with explanation
python-on-and-ot-with-explanation-by-unk-n3b0
\nTime Complexity: O(N)\nSpace Complexity: O(T)\n\n\n\nfrom collections import Counter\nclass Solution:\n def minWindow(self, s: str, t: str) -> str:\n\t\t#
Unkn0wnPerson
NORMAL
2021-01-08T06:43:17.396055+00:00
2021-01-08T08:07:58.167722+00:00
1,693
false
```\nTime Complexity: O(N)\nSpace Complexity: O(T)\n```\n\n```\nfrom collections import Counter\nclass Solution:\n def minWindow(self, s: str, t: str) -> str:\n\t\t# Count number of occurrences of each character from target string.\n t=Counter(t) \n\t\t\n #This will store number of unique characters ...
15
0
['Sliding Window', 'Python3']
2
minimum-window-substring
⭐✅ LOGICAL COMMENTS || EASY C++ CODE || Including logical comments
logical-comments-easy-c-code-including-l-9odz
Easy to understand code with complete comments:\n\n\nclass Solution {\npublic:\n string minWindow(string s, string t) {\n unordered_map<char, int>mp;\
SachinSahu
NORMAL
2022-06-22T05:24:18.500542+00:00
2022-11-08T13:54:19.178848+00:00
909
false
# Easy to understand code with complete comments:\n\n```\nclass Solution {\npublic:\n string minWindow(string s, string t) {\n unordered_map<char, int>mp;\n \n // keeping track of common char b/w s ans t\n for(auto i : t)\n mp[i]++;\n \n int start = 0,end =0; //...
14
0
['Two Pointers', 'C', 'Sliding Window', 'C++']
1
minimum-window-substring
C++ 😊 ADITYA VERMA SOLUTION 💖
c-aditya-verma-solution-by-sayan_11_mait-zoqn
\nclass Solution\n{\npublic:\n string minWindow(string s, string t)\n {\n unordered_map<char, int> mp;\n for (int i = 0; i < t.size(); i++)\
sayan_11_maitra
NORMAL
2022-01-14T16:41:51.422347+00:00
2022-09-17T10:08:58.417616+00:00
999
false
```\nclass Solution\n{\npublic:\n string minWindow(string s, string t)\n {\n unordered_map<char, int> mp;\n for (int i = 0; i < t.size(); i++)\n {\n mp[t[i]]++;\n }\n int count = mp.size();\n string ans;\n\n int mini = INT_MAX;\n\n int i = 0;\n ...
14
1
['C']
4
minimum-window-substring
C++ - 2 approaches for hashmap - way too much commenting and explanation
c-2-approaches-for-hashmap-way-too-much-9ptw2
The idea of sliding window is this:\n1. Start two pointers - begin and end, both at 0.\n2. Keep begin constant. Move end (i.e., do end++) till the condition is
kiyosaanb
NORMAL
2020-09-14T17:34:46.595961+00:00
2020-09-14T17:35:25.490167+00:00
1,932
false
**The idea of sliding window is this:**\n1. Start two pointers - begin and end, both at 0.\n2. Keep begin constant. Move end (i.e., do end++) till the condition is satisfied.\n3. Once the condition is satisfied, move the begin pointer (do begin++) for as long as the condition is still satisfied. Update the minLength an...
14
1
['C', 'C++']
5
minimum-window-substring
O( n )✅ | C++ (Step by step explanation)✅
o-n-c-step-by-step-explanation-by-monste-o5g2
Intuition\nThe problem requires finding the minimum window in string \'s\' that contains all characters from string \'t\'. We can use a sliding window approach
monster0Freason
NORMAL
2023-10-27T17:43:52.444678+00:00
2023-10-27T17:43:52.444710+00:00
1,673
false
# Intuition\nThe problem requires finding the minimum window in string \'s\' that contains all characters from string \'t\'. We can use a sliding window approach to solve this problem efficiently.\n\n# Approach\n1. First, we handle the edge case: if \'t\' is an empty string, we return an empty string as the result.\n\n...
13
0
['Sliding Window', 'C++']
1
minimum-window-substring
✅ [Python/Rust/C++] fast & concise using two-pointer sliding window (with detailed comments)
pythonrustc-fast-concise-using-two-point-3djq
\u2705 IF YOU LIKE THIS SOLUTION, PLEASE UPVOTE.\n*\nThis solution employs a two-pointer sliding window approach to search for the minimum substring. Time compl
stanislav-iablokov
NORMAL
2022-10-22T11:49:45.391794+00:00
2022-10-23T11:15:05.703121+00:00
1,639
false
**\u2705 IF YOU LIKE THIS SOLUTION, PLEASE UPVOTE.**\n****\nThis solution employs a two-pointer sliding window approach to search for the minimum substring. Time complexity is linear: **O(n+m)**. Space complexity is linear: **O(n)**. \n\n| Language | Runtime | Memory |\n|---|---|---|\n| [**Python**](https://leetcode.co...
13
1
['C', 'Python', 'Rust']
1
minimum-window-substring
JavaScript - 96.66 % better - used char Array instead if Hash Map
javascript-9666-better-used-char-array-i-u0sl
```\nvar minWindow = function(s, t) {\n \n let arr = new Array(128).fill(0); // Ascii charSet array to store count\n let result = [-Infinity, Infinity]
varungowde
NORMAL
2020-03-28T07:50:01.342088+00:00
2020-03-28T07:50:01.342126+00:00
3,396
false
```\nvar minWindow = function(s, t) {\n \n let arr = new Array(128).fill(0); // Ascii charSet array to store count\n let result = [-Infinity, Infinity] // result not yet known\n let missing = t.length; // missing words initially\n \n for(let i=0; i < t.length; i++){ // increase the count in arr\n ...
13
0
['Array', 'Sliding Window', 'JavaScript']
2
minimum-window-substring
Simple Python two-pointer solution
simple-python-two-pointer-solution-by-ot-on6e
Please see and vote for my solutions for these similar problems.\n1208. Get Equal Substrings Within Budget\n3. Longest Substring Without Repeating Characters\n1
otoc
NORMAL
2019-07-27T07:03:54.464836+00:00
2019-09-29T04:19:38.236871+00:00
1,345
false
Please see and vote for my solutions for these similar problems.\n[1208. Get Equal Substrings Within Budget](https://leetcode.com/problems/get-equal-substrings-within-budget/discuss/392901/Simple-Python-moving-window)\n[3. Longest Substring Without Repeating Characters](https://leetcode.com/problems/longest-substring-w...
13
0
[]
1
minimum-window-substring
Simple 2 pointer approach || Beats 100% 🔥🔥 || Python & CPP || T.C. : O(n) & S.C. : O(1)
simple-2-pointer-approach-beats-100-pyth-l7z8
IntuitionThe problem is about finding the smallest substring of s that contains all the characters of string t (including duplicates). The task can be efficient
devilshiv_07
NORMAL
2025-01-25T19:03:52.111077+00:00
2025-02-08T11:42:12.211457+00:00
2,060
false
![Screenshot 2025-01-26 001905.png](https://assets.leetcode.com/users/images/ad26705f-1343-43ea-b9eb-d5fdc4dab23f_1737831087.9904838.png) --- # Intuition The problem is about finding the smallest substring of s that contains all the characters of string t (including duplicates). The task can be efficiently solved usi...
12
0
['Hash Table', 'Two Pointers', 'Sliding Window', 'C++', 'Python3']
1
minimum-window-substring
C++ - Easiest Beginner Friendly Sol || Sliding window
c-easiest-beginner-friendly-sol-sliding-t54i5
Intuition of this Problem:\nReference - https://leetcode.com/problems/minimum-window-substring/solutions/26808/here-is-a-10-line-template-that-can-solve-most-su
singhabhinash
NORMAL
2023-02-04T13:34:44.302376+00:00
2023-02-04T13:34:44.302403+00:00
2,963
false
# Intuition of this Problem:\nReference - https://leetcode.com/problems/minimum-window-substring/solutions/26808/here-is-a-10-line-template-that-can-solve-most-substring-problems/?orderBy=hot\n<!-- Describe your first thoughts on how to solve this problem. -->\n**NOTE - PLEASE READ APPROACH FIRST THEN SEE THE CODE. YOU...
12
0
['Hash Table', 'Sliding Window', 'C++', 'Java', 'Python3']
3
minimum-window-substring
Simple c++ solution | Sliding Window | Hashmap | Explained clearly with comments
simple-c-solution-sliding-window-hashmap-wz1x
\n\n string minWindow(string s, string t) {\n // Initialize minl as INT_MAX\n int minl = INT_MAX;\n \n // Map to keep count of all c
maitreyeepaliwal
NORMAL
2021-07-24T19:49:59.753700+00:00
2021-07-24T19:49:59.753745+00:00
1,329
false
\n```\n string minWindow(string s, string t) {\n // Initialize minl as INT_MAX\n int minl = INT_MAX;\n \n // Map to keep count of all characters of t \n unordered_map <int, int> mp;\n for(auto ch: t) mp[ch]++;\n \n // Sliding Window Approach\n // Let c be t...
12
0
['Two Pointers', 'C', 'Sliding Window']
1
minimum-window-substring
Sliding Window Thinking Process
sliding-window-thinking-process-by-grace-4ti5
For example\n\ne.g. S = "ADOBECODEBANC", T = "ABC"\n ADOBEC \n\t BECODEBA \n CODEBA\n BANC\nThe substrings abov
gracemeng
NORMAL
2018-06-23T13:13:00.025631+00:00
2018-06-23T13:13:00.025631+00:00
1,064
false
> For example\n```\ne.g. S = "ADOBECODEBANC", T = "ABC"\n ADOBEC \n\t BECODEBA \n CODEBA\n BANC\nThe substrings above are candidates for the result.\n```\n> In Brute Force, \n```\nfor left in [0: sLen - 1]\n for right in [left*: sLen - 1]\n if (canCover()) \n\t upda...
12
1
[]
3
minimum-window-substring
My 12ms simple C++ code (O(1) space, O(N) time)
my-12ms-simple-c-code-o1-space-on-time-b-rslz
Just used an array dict to count the occurence of the letters in t. To distinguish the letters that are not in t, we initialize dict with -slen and for those le
lejas
NORMAL
2015-08-05T03:24:49+00:00
2015-08-05T03:24:49+00:00
3,697
false
Just used an array dict to count the occurence of the letters in t. To distinguish the letters that are not in t, we initialize dict with -slen and for those letters that are not in t, their corresponding elements in dict will be -slen. For example, t="abc", then dict['a']= dict['b']=dict['c']=1, while the others, suc...
12
1
[]
1
minimum-window-substring
Java, SlidingWindow, HashMap, TwoPointer Solution
java-slidingwindow-hashmap-twopointer-so-3hi4
plz... upvote! if you find my solution helpful.\n\nStatus: Accepted*\nRuntime: 4 ms\nMemory Usage: 43.9 MB\nAll test cases passed.\n\n
kumar-rinku0
NORMAL
2022-07-25T09:50:36.379176+00:00
2022-07-25T09:52:12.730683+00:00
2,272
false
***plz... upvote! if you find my solution helpful.***\n\nStatus: **Accepted***\nRuntime: 4 ms\nMemory Usage: 43.9 MB\nAll test cases passed.\n\n[<iframe src="https://leetcode.com/playground/jpJPCeKg/shared" frameBorder="0" width="800" height="600"></iframe>](http://)
11
0
['Sliding Window', 'Java']
3
minimum-window-substring
O(n) 5ms Java Solution Beats 93.18%
on-5ms-java-solution-beats-9318-by-longs-gr7t
This solution adopts the idea described in this [LeetCode article][1]. It explains this O(n) solution very well. Because of that article, I kept the comments si
longstation
NORMAL
2016-03-04T23:53:48+00:00
2016-03-04T23:53:48+00:00
5,275
false
This solution adopts the idea described in this [LeetCode article][1]. It explains this O(n) solution very well. Because of that article, I kept the comments simple. I highly suggest you to read it before trying this code.\n\n public class Solution {\n public String minWindow(String s, String t) {\n char...
11
0
['Java']
4
minimum-window-substring
[Animated Video] Sliding Window Template + Visualization
animated-video-sliding-window-template-v-q06l
CodeInMotion ResourcesEvery Leetcode Pattern You Need To Knowhttps://www.blog.codeinmotion.io/p/leetcode-patternsBlind 75 Animated Playlisthttps://www.youtube.c
codeinmotion
NORMAL
2025-01-03T22:03:54.784433+00:00
2025-01-03T22:03:54.784433+00:00
624
false
![Code In Motion Purple Transparent Background (2).png](https://assets.leetcode.com/users/images/69a60a6b-9c0f-4aa1-899b-98ee5f9b1dc1_1733778334.1189735.png) # *CodeInMotion Resources* ## Every Leetcode Pattern You Need To Know https://www.blog.codeinmotion.io/p/leetcode-patterns ## Blind 75 Animated Playlist https:/...
10
0
['Hash Table', 'String', 'Sliding Window', 'Python', 'C++', 'Java', 'Go', 'Python3', 'JavaScript', 'C#']
0
minimum-window-substring
C++ STL SOLUTION | | 2 APPROACHES | | EASY TO UNDERSTAND
c-stl-solution-2-approaches-easy-to-unde-338v
APPROACH 1\n\n## Approach\nSteps:\n1. We first create a hashmap for the characters of the string \'t\'.\n\n\nfor (auto value:t){\n m[value]++;\n}\n\n\n2. The
ALANT535
NORMAL
2024-02-04T07:36:02.503088+00:00
2024-02-04T07:36:02.503120+00:00
1,493
false
# APPROACH 1\n\n## Approach\nSteps:\n1. We first create a hashmap for the characters of the string \'t\'.\n\n```\nfor (auto value:t){\n m[value]++;\n}\n```\n\n2. Then we use two pointers, left and right to iterate through the string \'s\'. For each index, we do the following-\n\n\n2.1. If s[i] is inside m, the hashm...
10
0
['Hash Table', 'String', 'Sliding Window', 'C++']
6
minimum-window-substring
✔️ Python's Simple and Easy to Understand Solution Using Sliding Window | 99% Faster 🔥
pythons-simple-and-easy-to-understand-so-wvv7
\uD83D\uDD3C IF YOU FIND THIS POST HELPFUL PLEASE UPVOTE \uD83D\uDC4D\n\n\nclass Solution:\n def minWindow(self, s: str, t: str) -> str:\n lookup = Co
pniraj657
NORMAL
2022-10-22T05:27:11.294594+00:00
2022-10-31T05:28:42.546285+00:00
2,337
false
**\uD83D\uDD3C IF YOU FIND THIS POST HELPFUL PLEASE UPVOTE \uD83D\uDC4D**\n\n```\nclass Solution:\n def minWindow(self, s: str, t: str) -> str:\n lookup = Counter(t)\n mx = float("inf")\n output = ""\n S = len(s)\n start, end = 0, 0\n count = len(lookup)\n \n w...
10
0
['Sliding Window', 'Python', 'Python3']
2
minimum-window-substring
✔️ 100% Fastest Swift Solution
100-fastest-swift-solution-by-sergeylesc-cfcp
\nclass Solution {\n func minWindow(_ s: String, _ t: String) -> String {\n guard s.count >= t.count else { return "" }\n \n let sChars
sergeyleschev
NORMAL
2022-04-06T05:43:40.603423+00:00
2022-04-06T05:43:40.603468+00:00
1,271
false
```\nclass Solution {\n func minWindow(_ s: String, _ t: String) -> String {\n guard s.count >= t.count else { return "" }\n \n let sChars = Array(s)\n let tChars = Array(t)\n \n let indexs = validIndexs(sChars, tChars)\n guard s.count >= t.count else { return "" }\n ...
10
0
['Swift']
3
minimum-window-substring
C++|| Sliding Window|| Using arrays
c-sliding-window-using-arrays-by-hiteshc-650u
Runtime: 8 ms\n\n\nclass Solution {\npublic:\n string minWindow(string s, string t) {\n \n //frequency mapping\n int FP[256]={0};\n
hiteshcmonga
NORMAL
2021-06-09T15:28:27.804483+00:00
2021-06-09T15:29:01.647947+00:00
720
false
Runtime: 8 ms\n\n```\nclass Solution {\npublic:\n string minWindow(string s, string t) {\n \n //frequency mapping\n int FP[256]={0};\n int FS[256]={0};\n int cnt=0;\n int start=0; //left contraction\n int start_idx=-1 ;//for best window\n int min_so_far=INT_MAX...
10
3
['C', 'Sliding Window']
0
minimum-window-substring
Minimum window substring
minimum-window-substring-by-r9n-zyb4
\n\nusing System;\nusing System.Collections.Generic;\n\npublic class Solution\n{\n public string MinWindow(string s, string t)\n {\n if (s.Length =
r9n
NORMAL
2024-08-15T01:48:27.810142+00:00
2024-08-15T01:48:27.810165+00:00
261
false
\n```\nusing System;\nusing System.Collections.Generic;\n\npublic class Solution\n{\n public string MinWindow(string s, string t)\n {\n if (s.Length == 0 || t.Length == 0)\n return "";\n\n var required = new Dictionary<char, int>();\n var window = new Dictionary<char, int>();\n ...
9
0
['C#']
0
minimum-window-substring
Sliding Window 🪟 | Python 🐍 | CLEAR EXPLANATION 📒
sliding-window-python-clear-explanation-iumlu
Efficiency\n\n\n\n# Approach\nSliding Window algorithm: Create 2 pointers to identify the start and end points of the output string.\n1. First, we create a Hash
kcp_1410
NORMAL
2024-02-04T19:30:55.437579+00:00
2024-02-04T19:31:35.777700+00:00
149
false
# Efficiency\n![image.png](https://assets.leetcode.com/users/images/467a1421-dfa6-408d-a03a-f1ac7cc234e5_1707068041.8072896.png)\n\n\n# Approach\n**Sliding Window algorithm**: Create 2 pointers to identify the start and end points of the output string.\n1. First, we create a HashMap `t_chars` and count the occurrences ...
9
0
['Hash Table', 'String', 'Sliding Window', 'Python3']
2
minimum-window-substring
Beats 100% 🚀➡️Detailed Explanation 💯➡️[Java/C++/Python3/JavaScript]
beats-100-detailed-explanation-javacpyth-yh81
Intuition\n1. Window Creation with Two Pointers:\n - Use two pointers, one for the left end of the window and another for the right end, to create a window o
Shivansu_7
NORMAL
2024-02-04T09:52:18.108292+00:00
2024-02-04T09:52:18.108325+00:00
3,014
false
# Intuition\n1. **Window Creation with Two Pointers:**\n - Use two pointers, one for the left end of the window and another for the right end, to create a window of letters in string `s`.\n - This window should aim to contain all the characters present in string `t`.\n2. **Expanding the Window:**\n - Start by ...
9
0
['Sliding Window', 'C++', 'Java', 'Python3', 'JavaScript']
6
minimum-window-substring
🚀🚀 Beats 100% | Optimized Approach 🔥🔥 | Fully Explained 💎
beats-100-optimized-approach-fully-expla-xrvg
Intuition \uD83E\uDD14:\nWe are given two strings, s and t, and we need to find the minimum window substring in s that contains all characters of t. To approach
The_Eternal_Soul
NORMAL
2024-02-04T01:29:13.091631+00:00
2024-02-04T01:29:13.091660+00:00
2,351
false
### Intuition \uD83E\uDD14:\nWe are given two strings, `s` and `t`, and we need to find the minimum window substring in `s` that contains all characters of `t`. To approach this problem, we\'ll use two hash maps to keep track of characters in `s` and `t`, and then we\'ll use a sliding window technique to find the minim...
9
1
['Hash Table', 'String', 'C', 'Sliding Window', 'Python', 'C++', 'Java', 'JavaScript']
3
minimum-window-substring
SUPER EASY SOLUTION
super-easy-solution-by-himanshu__mehra-jfc9
Intuition\n Describe your first thoughts on how to solve this problem. \nhttps://www.youtube.com/watch?v=_t8kq_RpiPU\n\n# Code\n\nclass Solution {\npublic:\n
himanshu__mehra__
NORMAL
2023-07-11T18:00:27.491009+00:00
2023-07-11T18:00:27.491029+00:00
1,811
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nhttps://www.youtube.com/watch?v=_t8kq_RpiPU\n\n# Code\n```\nclass Solution {\npublic:\n string minWindow(string s, string t) {\n unordered_map<char,int> hast_s;\n unordered_map<char,int> hast_t;\n if(s.length()<t.l...
9
0
['Hash Table', 'Sliding Window', 'C++']
1
minimum-window-substring
Brute force to Optimal | Sliding Window | C++
brute-force-to-optimal-sliding-window-c-l91j6
Brute Force\n\nclass Solution {\n bool check(unordered_map<char, int> &mp, unordered_map<char, int> &m) {\n if(m.size() < mp.size()) return false;\n
TusharBhart
NORMAL
2022-10-22T05:19:36.454471+00:00
2022-10-22T05:19:36.454511+00:00
2,074
false
# Brute Force\n```\nclass Solution {\n bool check(unordered_map<char, int> &mp, unordered_map<char, int> &m) {\n if(m.size() < mp.size()) return false;\n for(auto i : m) {\n if(i.second < mp[i.first]) return false;\n }\n return true;\n }\npublic:\n string minWindow(string...
9
0
['Hash Table', 'Sliding Window', 'C++']
2
minimum-window-substring
Simple Python O(N) Sliding Window Explained with Example
simple-python-on-sliding-window-explaine-n2wn
O(N) Sliding Window Python Solution with Counter\n\ndef minWindow(self, s: str, t: str) -> str:\n\ttCounter = Counter(t) # counter for t to check with\n\twindow
bloomh
NORMAL
2022-10-22T03:54:39.488692+00:00
2022-10-23T04:38:53.947778+00:00
2,228
false
**O(N) Sliding Window Python Solution with Counter**\n```\ndef minWindow(self, s: str, t: str) -> str:\n\ttCounter = Counter(t) # counter for t to check with\n\twindow = Counter() # sliding window\n\tans = "" # answer\n\tlast = 0 # last index in our window\n\tfor i,char in enumerate(s):\n\t\twindow[char] = window.get(c...
9
0
['Sliding Window', 'Python']
3
minimum-window-substring
The most easy sliding window solution
the-most-easy-sliding-window-solution-by-7xtz
\nstring minWindow(string s, string t) {\n string res = "";\n if(s.size() < t.size()) return res;\n unordered_map<char, int> umap;\n
codingGuy2016
NORMAL
2022-05-11T18:04:52.697989+00:00
2022-05-11T18:04:52.698090+00:00
913
false
```\nstring minWindow(string s, string t) {\n string res = "";\n if(s.size() < t.size()) return res;\n unordered_map<char, int> umap;\n for(auto it: t) umap[it]++;\n int i=0, j=0;\n int length = INT_MAX, count = umap.size();\n while(j<s.size()){\n if(umap.find...
9
0
['C', 'Sliding Window', 'C++']
2
minimum-window-substring
[Python 3] From Brute Force to Sliding Window - 3 solutions - O(N)
python-3-from-brute-force-to-sliding-win-8wx9
Solution 1: Brute force\npython\nclass Solution:\n def minWindow(self, s: str, t: str) -> str:\n def isCover(cnt1, cnt2): # return True if all charact
hiepit
NORMAL
2021-08-16T16:09:46.569921+00:00
2023-08-21T13:51:12.776208+00:00
459
false
**Solution 1: Brute force**\n```python\nclass Solution:\n def minWindow(self, s: str, t: str) -> str:\n def isCover(cnt1, cnt2): # return True if all characters in cnt2 is covered by cnt1\n for k, v in cnt2.items():\n if cnt1[k] < v:\n return False\n ret...
9
1
['Sliding Window']
0
minimum-window-substring
[C++] Sliding Window || Easy To Understand
c-sliding-window-easy-to-understand-by-m-k9dp
IDEA\nWe keep expanding the window by moving the right pointer. When the window has all the desired characters, we contract (if possible) and save the smallest
Maango16
NORMAL
2021-08-15T08:52:17.480608+00:00
2021-08-15T08:52:17.480634+00:00
559
false
**IDEA**\nWe keep expanding the window by moving the right pointer. When the window has all the desired characters, we contract (if possible) and save the smallest window till now.\n`The answer is the smallest desirable window.`\n\u200B\n**EXAMPLE**\nFor eg. `S = "ABAACBAB" T = "ABC"`. Then our answer window is `"ACB"`...
9
4
[]
2
minimum-window-substring
Share my neat and easy-understand python solution in O(n)
share-my-neat-and-easy-understand-python-vprw
class Solution(object):\n '''\n b -- begin index of window; e -- end index of window.\n example: S="acbbaca", T="aba"\n \n 0
mach7
NORMAL
2015-10-14T23:03:52+00:00
2015-10-14T23:03:52+00:00
2,662
false
class Solution(object):\n '''\n b -- begin index of window; e -- end index of window.\n example: S="acbbaca", T="aba"\n \n 0 1 2 3 4 5 6\n a c b b a c a\n \n initially, b=e=0\n a:2\n b:1\n pc=2 (positive count. pc>0 indicates that there ar...
9
0
['Python']
1
minimum-window-substring
The fast 7ms O(N) Java solution use only one array without map
the-fast-7ms-on-java-solution-use-only-o-tni3
public String minWindow(String s, String t) {\n if (t.length() <= 0 || s.length() < t.length()) return "";\n int start = 0, end = 0, i = 0, j = 0,
alpenliebe
NORMAL
2016-01-13T21:26:57+00:00
2016-01-13T21:26:57+00:00
3,471
false
public String minWindow(String s, String t) {\n if (t.length() <= 0 || s.length() < t.length()) return "";\n int start = 0, end = 0, i = 0, j = 0, count = t.length(), min = s.length()+1;\n int[] table = new int[256];\n \n for(int k = 0; k<count; k++){\n char c = t.charA...
9
2
['Array', 'Dynamic Programming', 'Java']
1
minimum-window-substring
C++ post referred to top voted post
c-post-referred-to-top-voted-post-by-rai-bakx
First, thanks the post from @vinceyuan\n\nHere I just try explain it carefully so to help some beginners to better understand the inspiring ideas behind the sol
rainbowsecret
NORMAL
2016-02-20T11:06:22+00:00
2016-02-20T11:06:22+00:00
3,525
false
First, thanks the post from @vinceyuan\n\nHere I just try explain it carefully so to help some beginners to better understand the inspiring ideas behind the solution.\n\nPreprocessing step:\n\nstore the condition variable in the unordered_map\n\nWhile loop step:\n\n check sub-conditions, update global variable\n\...
9
1
[]
6
minimum-window-substring
Minimum Window Substring - Solution Explanation and Code (Video Solution Available)
minimum-window-substring-solution-explan-2t72
Video SolutionIntuitionThe problem involves finding the minimum window in the string s that contains all the characters of string t. My first thought was to use
CodeCrack7
NORMAL
2025-01-25T03:40:16.974122+00:00
2025-01-25T03:40:16.974122+00:00
979
false
# Video Solution [https://youtu.be/OoLytq4DRro?si=agfFSpEcxAEablx_]() # Intuition The problem involves finding the minimum window in the string `s` that contains all the characters of string `t`. My first thought was to use a sliding window approach with a frequency map to track the required characters and their counts...
8
0
['Java']
1
minimum-window-substring
🔥🔥🔥 Easy Sliding Window Solution | Explained 🔥🔥🔥
easy-sliding-window-solution-explained-b-0u59
Intuition\nThe main problem is finding the smallest substring in s that contains all the characters in t. Use the sliding window concept to solve this problem.\
pratamandiko
NORMAL
2024-02-04T02:43:51.157837+00:00
2024-02-04T02:43:51.157866+00:00
1,406
false
# Intuition\nThe main problem is finding the **smallest** substring in **s** that contains all the characters in **t**. Use the sliding window concept to solve this problem.\n\n# Approach\n**Character Frequency t:** We start by counting the frequency of each character in **t** using a hashmap.\n\n**Sliding Window Expan...
8
0
['Hash Table', 'String', 'Sliding Window', 'Python', 'C++', 'Java', 'Go', 'Python3', 'JavaScript']
0
minimum-window-substring
[Python] ✅ || Easy Mind Map Diagram || Two Pointer + Sliding Window [Dynamic Size] || Space O(m+n)
python-easy-mind-map-diagram-two-pointer-r7jt
Intuition\nThe "Minimum Window Substring" problem requires finding the smallest substring in s that contains all the characters of t. Initially, the challenge s
chitralpatil
NORMAL
2024-01-08T19:57:07.765945+00:00
2024-01-08T19:57:07.765972+00:00
944
false
# Intuition\nThe "Minimum Window Substring" problem requires finding the smallest substring in `s` that contains all the characters of `t`. Initially, the challenge seems to lie in efficiently checking if a substring contains all required characters, and then minimizing this substring. The key is realizing the dynamic ...
8
0
['Hash Table', 'Two Pointers', 'String', 'Sliding Window', 'Python3']
0
minimum-window-substring
🙎C++ || Easy || Daily LeetCoding Challenge (22nd October 2022)
c-easy-daily-leetcoding-challenge-22nd-o-dfrh
Easy to Understand\nIf understand the sol^n then Please Upvote\n\nclass Solution {\npublic:\n string minWindow(string s, string t) {\n if (s.size() <
spyder_master
NORMAL
2022-10-22T04:36:54.298965+00:00
2022-10-22T04:36:54.298993+00:00
5,674
false
# Easy to Understand\n**If understand the sol^n then Please Upvote**\n```\nclass Solution {\npublic:\n string minWindow(string s, string t) {\n if (s.size() < t.size() or s.empty()) {\n return "";\n }\n \n int i = 0, j = 0;\n int start = -1, len = INT_MAX;\n std::...
8
0
['Hash Table', 'C', 'Sliding Window']
2
minimum-window-substring
[Java] Sliding window | Aditya Verma
java-sliding-window-aditya-verma-by-naga-0gxp
\nclass Solution {\n public String minWindow(String s, String t) {\n \n Map<Character, Integer> map = new HashMap<>();\n for(char ch: t.
nagato19
NORMAL
2022-08-14T19:15:15.550855+00:00
2022-08-14T19:15:15.550907+00:00
807
false
```\nclass Solution {\n public String minWindow(String s, String t) {\n \n Map<Character, Integer> map = new HashMap<>();\n for(char ch: t.toCharArray())\n map.put(ch, map.getOrDefault(ch, 0) + 1);\n \n int count = map.size(), ansLength = Integer.MAX_VALUE;\n Stri...
8
0
['Sliding Window', 'Java']
0
minimum-window-substring
🔥 JAVA 2️⃣-pointer sliding window || Simple Explanation 👀😄
java-2-pointer-sliding-window-simple-exp-jkc8
\uD83D\uDCCC 2 pointer Sliding window with 2 Hashmaps \uD83D\uDC49\uD83C\uDFFB \'Acquired\' and \'Required\' \n\n ## \u2705 At any point of time we will find
Yash_kr
NORMAL
2022-06-13T09:55:10.298019+00:00
2022-06-22T05:02:02.859113+00:00
882
false
# \uD83D\uDCCC 2 pointer Sliding window with 2 Hashmaps \uD83D\uDC49\uD83C\uDFFB \'Acquired\' and \'Required\' \n\n ## \u2705 At any point of time we will find : Minimum window substring starting from ith index (i.e. first pointer )\n \n \u270D\uD83C\uDFFB **Notations** : \n1. acquired -> Hashmap containing detai...
8
0
['Two Pointers', 'Sliding Window', 'Java']
0
minimum-window-substring
Sliding window C++ solution
sliding-window-c-solution-by-workday-rzkr
Using a sliding window to increase the right boundary to include more elements. Once the sliding window includes all elements in the target array, try to increa
workday
NORMAL
2022-03-15T04:12:48.371258+00:00
2022-03-15T04:12:48.371327+00:00
542
false
Using a sliding window to increase the right boundary to include more elements. Once the sliding window includes all elements in the target array, try to increase the left boundary to decrease the size of the window until the window doesn\'t include all elements in the target array. Repeat the previous steps till the r...
8
0
['C', 'Sliding Window']
2
minimum-window-substring
JS optimized solution with explanations O(t+s) time O(t+s) space
js-optimized-solution-with-explanations-c6554
Note\n- Should be pretty straight forward if you did these problems before: 567-permutation-in-string, 438. Find All Anagrams in a String\n- Do those first.\n-
inxela
NORMAL
2022-02-17T00:04:44.457157+00:00
2022-02-17T17:25:31.038455+00:00
1,497
false
# Note\n- Should be pretty straight forward if you did these problems before: [567-permutation-in-string](https://leetcode.com/problems/permutation-in-string/), [438. Find All Anagrams in a String](https://leetcode.com/problems/find-all-anagrams-in-a-string/)\n- Do those first.\n- Here is the idea:\n1. create a hashmap...
8
0
['Two Pointers', 'Sliding Window', 'JavaScript']
0
minimum-window-substring
Aditya Verma Approach || Easy Hashmap with Sliding Window || Minimum Window Substring
aditya-verma-approach-easy-hashmap-with-h77av
\nif (t.length() > s.length()) {\n return "";\n}\n\nif (s == t)\n return s;\nunordered_map < char, int > m;\n\nfor (auto it: t) {\n m[it]++;\n}\n\nint cnt =
akshansh773
NORMAL
2021-10-01T06:39:55.185780+00:00
2023-03-20T06:22:11.087501+00:00
1,025
false
```\nif (t.length() > s.length()) {\n return "";\n}\n\nif (s == t)\n return s;\nunordered_map < char, int > m;\n\nfor (auto it: t) {\n m[it]++;\n}\n\nint cnt = m.size();\nint i = 0;\nint j = 0;\nint ans = INT_MAX;\nint start = -1;\nint end = -1;\nwhile (j < s.length()) {\n if (m.find(s[j]) != m.end()) {\n m[s[j]...
8
0
['C++']
1
minimum-window-substring
C++|| Commented || Easy to Understand || Sliding Window|| Map
c-commented-easy-to-understand-sliding-w-i7a9
\nclass Solution {\npublic:\n string minWindow(string s, string t)\n {\n unordered_map<char, int> mapt; // For frequency of characters of string t\
pragyatewary24
NORMAL
2021-08-15T18:22:13.661135+00:00
2021-08-15T18:22:13.661179+00:00
815
false
```\nclass Solution {\npublic:\n string minWindow(string s, string t)\n {\n unordered_map<char, int> mapt; // For frequency of characters of string t\n for(auto ch : t)\n {\n mapt[ch]++;\n }\n unordered_map<char, int> maps; // For frequency of characters of string s\n...
8
0
['C', 'Sliding Window']
2
minimum-window-substring
Easy to understand C++ sliding window technique
easy-to-understand-c-sliding-window-tech-090u
\nclass Solution {\npublic:\n string minWindow(string s, string t) {\n int mm = s.size(), n = t.size();\n unordered_map<char, int> m;\n
tejas702
NORMAL
2021-08-15T14:56:23.037338+00:00
2021-08-15T14:57:01.438480+00:00
588
false
```\nclass Solution {\npublic:\n string minWindow(string s, string t) {\n int mm = s.size(), n = t.size();\n unordered_map<char, int> m;\n for(int i=0;i<n;i++)m[t[i]]++;\n int l = 0, r = 0;\n int res = INT_MAX;\n string st = "";\n string ryan = s.substr(l,r-l+1);\n ...
8
6
['C', 'Sliding Window']
0
minimum-window-substring
Template for sliding window problems
template-for-sliding-window-problems-by-ex624
Inspired by the top post, I create my own template for sliding window problems. I feel it is more generic and is good for all the sliding window problems I stud
yu6
NORMAL
2020-08-26T01:22:23.091984+00:00
2021-01-03T19:27:33.267840+00:00
678
false
Inspired by the top post, I create my own template for sliding window problems. I feel it is more generic and is good for all the sliding window problems I studied so far.\n\n**The template**\n```\nwhile(r<n) {\n\t//process r\n\twhile(r cannot move) {\n\t\t//process l to free r\n\t\tl++;\n\t}\n\t//process r\n\tr++;\n}\...
8
0
[]
1
minimum-window-substring
Python 20 lines AC O(n) solution
python-20-lines-ac-on-solution-by-round1-bcxy
Idea is pretty simple, keep two pointers left and right.\n\n If s[left:right] has all chars in T, calculate distance and keep answer, then move left pointer.\n\
round1lc
NORMAL
2015-05-12T06:48:28+00:00
2015-05-12T06:48:28+00:00
4,858
false
Idea is pretty simple, keep two pointers left and right.\n\n If s[left:right] has all chars in T, calculate distance and keep answer, then move left pointer.\n\n If s[left:right] doesn't have all chars in T, move right pointer.\n\n\n class Solution:\n # @param {string} s\n # @param {string} t\n # @return {s...
8
0
['Python']
3
minimum-window-substring
Sliding Window Explained || Beginner-friendly
sliding-window-explained-beginner-friend-ojis
IntuitionAs we need to check for substring, window would be the best approach to handle this. The only issue was deciding when to shrink. Once we find all the e
Bulba_Bulbasar
NORMAL
2025-01-26T08:23:14.219517+00:00
2025-01-26T08:30:42.968145+00:00
1,107
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> As we need to check for substring, window would be the best approach to handle this. The only issue was deciding when to shrink. Once we find all the elements we will shrink the window from left till the next element and then look for the m...
7
0
['Hash Table', 'Two Pointers', 'Sliding Window', 'Java']
1
minimum-window-substring
✅HARD MADE EASY | SLIDING WINDOW | JAVA | Explained🔥🔥🔥
hard-made-easy-sliding-window-java-expla-3mx4
Problem: Find the minimum window substring in string S which will contain all the characters in string T in inclusion and order.\n\nApproach:\n\nWe employ a sli
AdnanNShaikh
NORMAL
2024-08-16T16:41:58.405132+00:00
2024-08-16T16:41:58.405173+00:00
730
false
**Problem**: Find the minimum window substring in string S which will contain all the characters in string T in inclusion and order.\n\n**Approach**:\n\nWe employ a sliding window technique, where we maintain a window of characters in string S.\nA HashMap is used to keep track of the characters in string T and their re...
7
0
['Java']
1
minimum-window-substring
Easy to Understand, C++ solution Sliding Window's Most Important Question
easy-to-understand-c-solution-sliding-wi-8z8q
Intuition\nAs we see the problems of String and Array, in which we have to optimise the solution and we have to perform sequential operations on those problems.
sribhargav1345
NORMAL
2024-02-04T06:26:29.617144+00:00
2024-02-04T06:26:29.617174+00:00
1,288
false
# Intuition\nAs we see the problems of String and Array, in which we have to optimise the solution and we have to perform sequential operations on those problems. We need to think of **Sliding Window**\n\n# Approach\nStore the elements of string \'t\' in a map, and compare that with the elements of string \'s\', and if...
7
0
['Ordered Map', 'Sliding Window', 'C++']
1
minimum-window-substring
✔️ ✔️Beat 97.97%|| Sliding Window Approach with Clear Comments and Explanation
beat-9797-sliding-window-approach-with-c-ww6s
Please upvote if you find the solution helpful.\n\n\n## Explanation\n\n1. Initialization:\n - Create a character frequency map mp1 for string t.\n - Initial
Inam_28_06
NORMAL
2024-02-04T01:10:30.818487+00:00
2024-02-04T03:37:43.827510+00:00
1,311
false
Please **upvote** if you find the solution helpful.\n![image](https://assets.leetcode.com/users/images/8de3a02c-f6c5-401a-8347-abafc58acb70_1707009383.8935752.png)\n\n## Explanation\n\n1. **Initialization**:\n - Create a character frequency map `mp1` for string `t`.\n - Initialize sliding window pointers `i` and `j...
7
0
['C', 'Sliding Window', 'Python', 'Java']
0
minimum-window-substring
O( n )✅ | Python (Step by step explanation)✅
o-n-python-step-by-step-explanation-by-m-q7j2
Intuition\nThe problem requires finding the minimum window in string \'s\' that contains all characters from string \'t\'. We can use a sliding window approach
monster0Freason
NORMAL
2023-10-27T07:34:54.036360+00:00
2023-10-27T07:34:54.036381+00:00
485
false
# Intuition\nThe problem requires finding the minimum window in string \'s\' that contains all characters from string \'t\'. We can use a sliding window approach to solve this problem efficiently.\n\n# Approach\n1. First, we handle the edge case: if \'t\' is an empty string, we return an empty string as the result.\n\n...
7
0
['Sliding Window', 'Python3']
0
apply-operations-to-an-array
🚀 Beats 100% | In-Place Processing + Zero Shifting | Apply Operations on Array
beats-100-in-place-processing-zero-shift-p3w7
Youtube🚀 Beats 100% | In-Place Processing + Zero Shifting | Apply Operations on Array🔼 Please Upvote🔼 Please Upvote🔼 Please Upvote🔼 Please Upvote💡 If this helpe
rahulvijayan2291
NORMAL
2025-03-01T03:38:56.513541+00:00
2025-03-01T03:38:56.513541+00:00
18,214
false
# Youtube https://youtu.be/81UhXYJOz1g ![image.png](https://assets.leetcode.com/users/images/3494c257-469b-4399-a3bd-f8f6ea6ee477_1740799406.261016.png) --- # 🚀 Beats 100% | In-Place Processing + Zero Shifting | Apply Operations on Array --- # **🔼 Please Upvote** # **🔼 Please Upvote** # **🔼 Please Upvote...
74
3
['Array', 'C', 'C++', 'Java', 'TypeScript', 'Python3', 'JavaScript', 'C#']
6
apply-operations-to-an-array
✅✅✅ C++ & Java || O(n) time & O(1) space || Very Simple and Easy to Understand
c-solution-on-time-o1-space-very-simple-2l5hy
Approach: Simply change the value of nums[i] to 2 times & set nums[i+1] to zero when nums[i] == nums[i+1]. Then take a pointer and keep on accumulating non zero
kreakEmp
NORMAL
2022-11-06T04:00:38.429018+00:00
2025-03-01T07:13:05.365924+00:00
6,232
false
# Approach: - Simply change the value of nums[i] to 2 times & set nums[i+1] to zero when nums[i] == nums[i+1]. - Then take a pointer and keep on accumulating non zero value at the front. - Set all remaining values to zero, utill pointer is less then size of the array. ```cpp [] vector<int> applyOperations(vector<int...
65
9
['C++', 'Java']
11
apply-operations-to-an-array
One Pass [C++/Java/Python3]
one-pass-cjavapython3-by-xxvvpp-za84
Just do Operation and Swapping of non-zeroes at front of array simultaneously.\n# C++\n vector applyOperations(vector& A) {\n for (int i = 0, j = 0; i
xxvvpp
NORMAL
2022-11-06T04:01:46.657909+00:00
2022-11-06T08:15:39.924890+00:00
2,977
false
Just do `Operation` and `Swapping of non-zeroes at front` of array simultaneously.\n# C++\n vector<int> applyOperations(vector<int>& A) {\n for (int i = 0, j = 0; i < size(A); ++i){\n if (i + 1 < size(A) and A[i] == A[i + 1]){\n A[i] *= 2;\n A[i + 1] = 0;\n ...
56
2
['C']
5
apply-operations-to-an-array
✅ Two Pointers | Python | C++ | Java | C# | JS | Go | Swift | PHP | Rust | Kotlin | Dart | Ruby
two-pointers-python-by-otabek_kholmirzae-kumt
IntuitionThe problem involves two distinct operations: first, we need to perform a series of comparisons and modifications on adjacent elements, and then we nee
otabek_kholmirzaev
NORMAL
2025-03-01T08:44:49.113410+00:00
2025-03-01T10:30:19.084090+00:00
6,009
false
# Intuition **The problem involves two distinct operations:** first, we need to perform a series of comparisons and modifications on adjacent elements, and then we need to move all zeros to the end of the array. A natural way to approach this is to follow the instructions step by step. # Approach 1. **Apply Operations...
49
0
['Swift', 'Python', 'C++', 'Java', 'Go', 'Python3', 'Rust', 'Kotlin', 'JavaScript', 'C#']
3
apply-operations-to-an-array
✅ [Python/C++] use the NOT trick to move zeros (explained)
pythonc-use-the-not-trick-to-move-zeros-e54cc
\u2705 IF YOU LIKE THIS SOLUTION, PLEASE UPVOTE.\n*\nThis solution employs a brute force approach to perform operations along with (stable-)sorting using a *log
stanislav-iablokov
NORMAL
2022-11-06T04:00:48.478990+00:00
2022-11-06T05:19:33.054526+00:00
2,892
false
**\u2705 IF YOU LIKE THIS SOLUTION, PLEASE UPVOTE.**\n****\nThis solution employs a brute force approach to perform operations along with (stable-)sorting using a **logical not** trick to move zeros to the end of array. Time complexity is linear: **O(N\\*logN)**. Space complexity is linear: **O(N)**.\n\n\n**Python.**\n...
37
1
[]
10
apply-operations-to-an-array
✅2 Method's ||🌟JAVA||🧑‍💻 BEGINNER FREINDLY||C++||Python3
2-methods-java-beginner-freindlycpython3-gdqh
Approach 1: Two-Pass1.Apply Operations and Shift Zeros in a Single Pass: . Use a pointer index to track the position where the next non-zero element should be
Varma5247
NORMAL
2025-03-01T00:41:28.990563+00:00
2025-03-01T05:42:01.649157+00:00
2,847
false
# Approach 1: Two-Pass <!-- Describe your approach to solving the problem. --> **1.Apply Operations and Shift Zeros in a Single Pass:** . Use a pointer ```index``` to track the position where the next non-zero element should be placed. .Iterate through the array: .If the current element (```nums[i]```) is equal ...
22
0
['Array', 'Two Pointers', 'Python', 'C++', 'Java', 'TypeScript', 'Python3', 'JavaScript']
1
apply-operations-to-an-array
2 pointers O(1) space vs 1 loop||C++ Py3 beats 100%
2-passes-2-pointers-o1-spacec-beats-100-gs9qz
Intuition1st pass is for applying operations 2nd pass use 2 pointers to reuse the array nums for the answer Both C++ & Python are made.a 1 loop solution is also
anwendeng
NORMAL
2025-03-01T00:17:41.882187+00:00
2025-03-01T02:56:39.007387+00:00
2,249
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> 1st pass is for applying operations 2nd pass use 2 pointers to reuse the array nums for the answer Both C++ & Python are made. a 1 loop solution is also made. # Approach <!-- Describe your approach to solving the problem. --> 1. Use a loop...
17
0
['Two Pointers', 'C++', 'Python3']
5
apply-operations-to-an-array
✅✅🔥BEATS 96.37% SIMPLEST PROGRAM | JAVA 🔥 Python 🔥 C++ 🔥 JS 🔥 | Simplest Program |  O(n) & O(1)
beats-9637-simplest-program-java-python-zotsv
IntuitionThis method modifies the given array based on certain operations: If two consecutive elements are equal, double the first one and set the second one to
peEAWW4Y33
NORMAL
2025-03-01T12:12:23.310810+00:00
2025-03-01T12:12:23.310810+00:00
596
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> This method modifies the given array based on certain operations: - If two consecutive elements are equal, double the first one and set the second one to 0. - Shift all non-zero elements to the left while maintaining their relative order. ...
15
0
['Two Pointers', 'Python', 'C++', 'Java', 'JavaScript']
0
apply-operations-to-an-array
Python 3 || 6 lines, iteration || T/S: 99% / 52%
python-3-6-lines-iteration-ts-99-52-by-s-bsbl
[https://leetcode.com/problems/apply-operations-to-an-array/submissions/1166861606/?submissionId=1166861050)updateI could be wrong, but I think that time comple
Spaulding_
NORMAL
2022-11-06T07:05:15.846795+00:00
2025-03-01T01:28:10.872483+00:00
945
false
```Python3 [] class Solution: def applyOperations(self, nums: List[int]) -> List[int]: for i in range(len(nums)-1): if nums[i] == nums[i+1]: nums[i]*= 2 nums[i + 1] = 0 # <-- performing the "operation." nums.sort(key=lambda x: x == 0) # Sorti...
14
0
['C++', 'Java', 'Python3']
5
apply-operations-to-an-array
✅c++|| Simple solution|| Move Zeroes problem extension || O(1) space
c-simple-solution-move-zeroes-problem-ex-dgec
The idea is super simple go through all n - 1 elements and see if condition satisifies\nthen the problem is move all zeroes to end \nwe solve it using two point
dinesh55
NORMAL
2022-11-06T04:02:37.108295+00:00
2022-11-06T06:49:57.678610+00:00
941
false
The idea is super simple go through all n - 1 elements and see if condition satisifies\nthen the problem is move all zeroes to end \nwe solve it using two pointers \n\nLink to move zeroes to end problem :- <b>[Move Zeroes Problem](https://leetcode.com/problems/move-zeroes/)</b>\n\n```c++\nclass Solution {\npublic:\n ...
11
1
['C']
0
apply-operations-to-an-array
✅Simple Java Solutions in O(N) || ✅Runtime 0ms || ✅ Beats 100%
simple-java-solutions-in-on-runtime-0ms-t5v1y
\n# Intuition\nDescribe your first thoughts on how to solve this problem. \n\n\n\nThis code defines a `Solution` class with a method called `applyOperations`,
ahmedna126
NORMAL
2023-09-27T16:28:12.413227+00:00
2023-11-07T11:36:10.517206+00:00
398
false
<!-- \n# Intuition\nDescribe your first thoughts on how to solve this problem. \n\n\n\nThis code defines a `Solution` class with a method called `applyOperations`, which takes an integer array `nums` as input and returns another integer array as output. The goal of this code is to perform certain operations on the inp...
10
0
['Java']
0
apply-operations-to-an-array
✅C++|| Simple Traversal || Easy Solution
c-simple-traversal-easy-solution-by-indr-i7k6
\nclass Solution {\npublic:\n vector<int> applyOperations(vector<int>& nums) {\n int n=nums.size();\n\n vector<int>ans;\n \n for(
indresh149
NORMAL
2022-11-06T04:04:07.403275+00:00
2022-11-06T04:04:07.403318+00:00
1,264
false
```\nclass Solution {\npublic:\n vector<int> applyOperations(vector<int>& nums) {\n int n=nums.size();\n\n vector<int>ans;\n \n for(int i=0;i<n-1;i++)\n {\n if(nums[i]==nums[i+1])\n {\n nums[i]=2*nums[i];\n \n nums[...
10
0
['C']
1
apply-operations-to-an-array
JavaScript easy and fast solution (93.71% faster)
javascript-easy-and-fast-solution-9371-f-8oag
\n\n\n\n* only sort the zeros: nums.sort((a,b)=> !a - !b)\n\n\n# Code\n\n/**\n * @param {number[]} nums\n * @return {number[]}\n */\nvar applyOperations = func
fahim_ash
NORMAL
2022-11-14T08:34:31.993881+00:00
2022-11-14T08:35:15.490547+00:00
496
false
\n\n\n\n* only sort the zeros: nums.sort((a,b)=> !a - !b)\n\n\n# Code\n```\n/**\n * @param {number[]} nums\n * @return {number[]}\n */\nvar applyOperations = function(nums) {\n for (let i=0;i<nums.length;i++){\n if (nums[i]==nums[i+1]){\n [nums[i],nums[i+1]]=[nums[i]*2,0];\n }\n }return ...
9
0
['JavaScript']
0