{"id":1338,"date":"2020-06-10T19:09:36","date_gmt":"2020-06-10T19:09:36","guid":{"rendered":"https:\/\/blog.prepbytes.com\/?p=1338"},"modified":"2022-11-18T12:16:19","modified_gmt":"2022-11-18T12:16:19","slug":"minimum-window-substring","status":"publish","type":"post","link":"https:\/\/prepbytes.com\/blog\/minimum-window-substring\/","title":{"rendered":"Minimum Window Substring"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645179916103-Article_411.png\" alt=\"\" \/><\/p>\n<blockquote>\n<p>Find the minimum size of the substring of string <code>S<\/code> which contains all the character from a given string <code>T<\/code>. Print the substring with minimum length.<\/p>\n<\/blockquote>\n<p><a href=\"https:\/\/mycode.prepbytes.com\/problems\/strings\/MINWINSUB\" title=\"Go to mycode.prepbytes.com\" target=\"_blank\" rel=\"noopener noreferrer\"><u><strong><\/strong><\/u><\/a><\/p>\n<h3>Test Case<\/h3>\n<pre><code>Input:\n1\nprepbytes\npyte\nccbabcab\nbbab\n\nOutput:\npbyte\nbabcab\n\nExplanation:\nCase 1: All characters in string 'pyte' are present in 'pbyte' and this is the smallest substring.\nCase 2: All characters in string 'bbab' are present in strings 'babcab' and this is the smallest substring containing all characters.<\/code><\/pre>\n<h2>Bruteforce Approach to Solve the Minimum Window Substring Problem &#8211;<\/h2>\n<blockquote>\n<p>1) We can generate all substrings of string <code>S<\/code>.<br \/>\n2) For each substring we check if it contains all character from the string <code>T<\/code>.<br \/>\n3) We print the string with minimum length.<br \/>\n4) You can see this approach is not efficient and takes O(<code>T\\times{N^{2}}<\/code>) time as it takes O(<code>N^{2}<\/code>) time for calculating all substrings and takes O(<code>T<\/code>) time for checking if all characters from <code>T<\/code> exists or not in the substring.<br \/>\n5) Do you have any other approach which is efficient than this approach? Try that out, if that one goes beyond the time limit, proceed to the following efficient approach.<\/p>\n<\/blockquote>\n<pre><code>In the above approach, we found all substring containing all characters from our pattern string, we can also observe that all discarded substring contain or minimum window substring, and the largest such substring starts from 0. Hence we can find a substring from the start of the string containing all characters from the pattern, and then discard characters from beginning one by one, until we reach a condition that violates our requirements. We discuss this approach our efficient approach<\/code><\/pre>\n<h2>Efficient Approach to Solve the Minimum Window Substring Problem:<\/h2>\n<blockquote>\n<p>1) First check if the length of string <code>S<\/code> is less than the length of the given string <code>T<\/code>, if yes print <code>Not Found<\/code>.<br \/>\n2) If no, then store the occurrences of characters from string <code>T<\/code> in a hash table.<br \/>\n3) Start matching the characters of string <code>T<\/code> with the characters of string i.e. increment count if a character matches.<br \/>\n4) Check if the count is equal to the length of string <code>T<\/code>, if yes we have found a window containing all characters from the string <code>T<\/code>.<br \/>\n5) If such a window is found, try to minimize it by removing extra characters from the beginning of the current window.<br \/>\n6) Update the minimum length on each character removal.<br \/>\n7) Print the window with minimum length when no character can be removed.<\/p>\n<\/blockquote>\n<h3>Example<\/h3>\n<blockquote>\n<ul>\n<li>Let us take an example and understand above approach, let string <code>S<\/code> be &#8216;<code>qabaaab<\/code>&#8216; and pattern <code>P<\/code> be &#8216;<code>baaab<\/code>&#8216;.<\/li>\n<li>We maintain a hash table <code>hash_str<\/code> to store characters from string. We also maintain a hash table <code>hash_pat<\/code> to store characters from pattern string.<\/li>\n<li>We find all appearances of characters in <code>hash_pat<\/code>, so final <code>hash_pat<\/code> for pattern is <code>[3,2]<\/code> where index <code>0<\/code> corresponds for character <code>a<\/code> and index <code>1<\/code> corresponds for character <code>b<\/code>.<\/li>\n<li>We now find the largest window containing all character from pattern string, this can be found by starting window from <code>0<\/code> and increasing end of window one by one until whole window contains all chracters from pattern string.<br \/>\nHash table for string is initialised with 0, so default hash table is <code>[0,0,0]<\/code> where index <code>0<\/code> corresponds to <code>&#039;a&#039;<\/code>, index <code>1<\/code> corresponds to <code>&#039;b&#039;<\/code> and index <code>2<\/code> corresponds to <code>&#039;q&#039;<\/code>.<\/li>\n<\/ul>\n<\/blockquote>\n<p><strong><em>Finding Window :<\/em><\/strong><\/p>\n<blockquote>\n<p>We also maintain a counter <code>count<\/code>, which when equal to length of pattern, we exit because that is last point of window.<\/p>\n<\/blockquote>\n<p><strong><em>For end = 0:<\/em><\/strong><\/p>\n<blockquote>\n<p>Current character is <code>&#039;q&#039;<\/code>, hence <code>hash_str<\/code> becomes <code>[0,0,1]<\/code>, &#8216;q&#8217; does not appear in pattern, so we don&#8217;t increase <code>count<\/code>.<\/p>\n<\/blockquote>\n<p><strong><em>For end = 1:<\/em><\/strong><\/p>\n<blockquote>\n<p>Current character is <code>&#039;a&#039;<\/code>, hence <code>hash_str<\/code> becomes <code>[1,0,1]<\/code>, hash_str value is less than hash_pat value of &#8216;a&#8217;, so we increase counter by 1, so <code>count=1<\/code>.<\/p>\n<\/blockquote>\n<p><strong><em>For end = 2:<\/em><\/strong><\/p>\n<blockquote>\n<p>Current character is <code>&#039;b&#039;<\/code>, hence <code>hash_str<\/code> becomes <code>[1,1,1]<\/code>, hash_str value is less than hash_pat value of &#8216;a&#8217;, so we increase counter by 1, so <code>count=2<\/code>.<\/p>\n<\/blockquote>\n<p><strong><em>For end = 3:<\/em><\/strong><\/p>\n<blockquote>\n<p>Current character is <code>&#039;a&#039;<\/code>, hence <code>hash_str<\/code> becomes <code>[2,1,1]<\/code>, hash_str value is less than hash_pat value of &#8216;a&#8217;, so we increase counter by 1, so <code>count=3<\/code>.<\/p>\n<\/blockquote>\n<p><strong><em>For end = 4:<\/em><\/strong><\/p>\n<blockquote>\n<p>Current character is <code>&#039;a&#039;<\/code>, hence <code>hash_str<\/code> becomes <code>[3,1,1]<\/code>, hash_str value is equal to hash_pat value of &#8216;a&#8217;, so we increase counter by 1, so <code>count=4<\/code>.<\/p>\n<\/blockquote>\n<p><strong><em>For end = 5:<\/em><\/strong><\/p>\n<blockquote>\n<p>Current character is <code>&#039;a&#039;<\/code>, hence <code>hash_str<\/code> becomes <code>[4,1,1]<\/code>, hash_str value is greater than hash_pat value of &#8216;a&#8217;, so we dont increase counter, so <code>count=4<\/code>.<\/p>\n<\/blockquote>\n<p><strong><em>For end = 6:<\/em><\/strong><\/p>\n<blockquote>\n<p>Current character is <code>&#039;b&#039;<\/code>, hence <code>hash_str<\/code> becomes <code>[4,2,1]<\/code>, hash_str value is less than hash_pat value of &#8216;a&#8217;, so we increase counter by 1, so <code>count=5<\/code>.<\/p>\n<\/blockquote>\n<p>Hence count is now equal to length of pattern, so we have found the window of maximum length, now we need to short this window for minimum size of window.<\/p>\n<blockquote><\/blockquote>\n<p><strong><em>Minimizing The Window :<\/em><\/strong><\/p>\n<blockquote>\n<p>Here, we move start pointer of window to minimize the size, we decrease the count of hash_str value of current character if hash_str value is greater than hash_pat value of current character. If hash_str value becomes becomes less to hash_pat value of current character, we stop iterating, current window is the minimum window.<\/p>\n<\/blockquote>\n<p><strong><em>For start = 0:<\/em><\/strong><\/p>\n<blockquote>\n<p>Current character is <code>&#039;q&#039;<\/code>, hence <code>hash_str<\/code> becomes <code>[4,2,0]<\/code>, hash_str value is not in pattern so we move further.<\/p>\n<\/blockquote>\n<p><strong><em>For start = 1:<\/em><\/strong><\/p>\n<blockquote>\n<p>Current character is <code>&#039;a&#039;<\/code>, hence <code>hash_str<\/code> becomes <code>[3,2,0]<\/code>, hash_str value of &#8216;a&#8217; is greater than hash_pat value, so we move window further.<\/p>\n<\/blockquote>\n<p><strong><em>For start = 2:<\/em><\/strong><\/p>\n<blockquote>\n<p>Current character is <code>&#039;b&#039;<\/code>, hence <code>hash_str<\/code> becomes <code>[2,2,0]<\/code>, hash_str value of &#8216;a&#8217; is equal to hash_pat value, so we have minimized the window.<\/p>\n<\/blockquote>\n<p>We print the final window starting from start to end pointer. Hence we print <code>&#039;baaab&#039;<\/code>.<\/p>\n<h2>Program of the Solution of Minimum Window Substring Problem<\/h2>\n<p>\t\t\t\t\t\t<style>\r\n\t\t\t\t\r\n\t\t\t\t\t#tab_container_1341 {\r\n\toverflow:hidden;\r\n\tdisplay:block;\r\n\twidth:100%;\r\n\tborder:0px solid #ddd;\r\n\tmargin-bottom:30px;\r\n\t}\r\n\r\n#tab_container_1341 .tab-content{\r\n\tpadding:20px;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n\tmargin-top: 0px;\r\n\tbackground-color:#ffffff !important;\r\n\tcolor: #000000 !important;\r\n\tfont-size:16px !important;\r\n\tfont-family: Open Sans !important;\r\n\t\r\n\t\tborder: 1px solid #e6e6e6 !important;\r\n\t}\r\n#tab_container_1341 .wpsm_nav-tabs {\r\n    border-bottom: 0px solid #ddd;\r\n}\r\n#tab_container_1341 .wpsm_nav-tabs > li.active > a, #tab_container_1341 .wpsm_nav-tabs > li.active > a:hover, #tab_container_1341 .wpsm_nav-tabs > li.active > a:focus {\r\n\tcolor: #000000 !important;\r\n\tcursor: default;\r\n\tbackground-color: #ffffff !important;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n}\r\n\r\n#tab_container_1341 .wpsm_nav-tabs > li > a {\r\n    margin-right: 0px !important; \r\n    line-height: 1.42857143 !important;\r\n    border: 1px solid #d5d5d5 !important;\r\n    border-radius: 0px 0px 0 0 !important; \r\n\tbackground-color: #e8e8e8 !important;\r\n\tcolor: #000000 !important;\r\n\tpadding: 15px 18px 15px 18px !important;\r\n\ttext-decoration: none !important;\r\n\tfont-size: 14px !important;\r\n\ttext-align:center !important;\r\n\tfont-family: Open Sans !important;\r\n}\r\n#tab_container_1341 .wpsm_nav-tabs > li > a:focus {\r\noutline: 0px !important;\r\n}\r\n\r\n#tab_container_1341 .wpsm_nav-tabs > li > a:before {\r\n\tdisplay:none !important;\r\n}\r\n#tab_container_1341 .wpsm_nav-tabs > li > a:after {\r\n\tdisplay:none !important ;\r\n}\r\n#tab_container_1341 .wpsm_nav-tabs > li{\r\npadding:0px !important ;\r\nmargin:0px;\r\n}\r\n\r\n#tab_container_1341 .wpsm_nav-tabs > li > a:hover , #tab_container_1341 .wpsm_nav-tabs > li > a:focus {\r\n    color: #000000 !important;\r\n    background-color: #e8e8e8 !important;\r\n\tborder: 1px solid #d5d5d5 !important;\r\n\t\r\n}\r\n#tab_container_1341 .wpsm_nav-tabs > li > a .fa{\r\n\r\nmargin-right:5px !important;\r\n\r\nmargin-left:5px !important;\r\n\r\n\r\n}\r\n\r\n\t\t#tab_container_1341 .wpsm_nav-tabs a{\r\n\t\t\tbackground-image: none;\r\n\t\t\tbackground-position: 0 0;\r\n\t\t\tbackground-repeat: repeat-x;\r\n\t\t}\r\n\t\t\t\r\n\r\n\r\n#tab_container_1341 .wpsm_nav-tabs > li {\r\n    float: left;\r\n    margin-bottom: -1px !important;\r\n\tmargin-right:0px !important; \r\n}\r\n\r\n\r\n#tab_container_1341 .tab-content{\r\noverflow:hidden !important;\r\n}\r\n\r\n\r\n@media (min-width: 769px) {\r\n\r\n\t#tab_container_1341 .wpsm_nav-tabs > li{\r\n\t\tfloat:left !important ;\r\n\t\t\t\tmargin-right:-1px !important;\r\n\t\t\t\t\t}\r\n\t#tab_container_1341 .wpsm_nav-tabs{\r\n\t\tfloat:none !important;\r\n\t\tmargin:0px !important;\r\n\t}\r\n\r\n\t#tab_container_1341 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_1341 .wpsm_nav{\r\n\t\t\t}\r\n\r\n}\r\n\r\n\r\n\r\n@media (max-width: 768px) {\r\n\t#tab_container_1341 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_1341 .wpsm_nav{\r\n\t\t\t}\r\n}\r\n\r\n\r\n\t.wpsm_nav-tabs li:before{\r\n\t\tdisplay:none !important;\r\n\t}\r\n\r\n\t@media (max-width: 768px) {\r\n\t\t\t\t\r\n\t\t\t\t.wpsm_nav-tabs{\r\n\t\t\tmargin-left:0px !important;\r\n\t\t\tmargin-right:0px !important; \r\n\t\t\t\r\n\t\t}\r\n\t\t\t\t#tab_container_1341 .wpsm_nav-tabs > li{\r\n\t\t\tfloat:none !important;\r\n\t\t}\r\n\t\t\t\r\n\t}\t\t\t\t<\/style>\r\n\t\t\t\t<div id=\"tab_container_1341\" >\r\n\t \r\n\t\t\t\t\t<ul class=\"wpsm_nav wpsm_nav-tabs\" role=\"tablist\" id=\"myTab_1341\">\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t<li role=\"presentation\"  class=\"active\"  onclick=\"do_resize()\">\r\n\t\t\t\t\t\t\t\t<a href=\"#tabs_desc_1341_1\" aria-controls=\"tabs_desc_1341_1\" role=\"tab\" data-toggle=\"tab\">\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-code\"><\/i> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t<span>C<\/span>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t<\/a>\r\n\t\t\t\t\t\t\t<\/li>\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t<li role=\"presentation\"  onclick=\"do_resize()\">\r\n\t\t\t\t\t\t\t\t<a href=\"#tabs_desc_1341_2\" aria-controls=\"tabs_desc_1341_2\" role=\"tab\" data-toggle=\"tab\">\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-code\"><\/i> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t<span>C++<\/span>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t<\/a>\r\n\t\t\t\t\t\t\t<\/li>\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t<li role=\"presentation\"  onclick=\"do_resize()\">\r\n\t\t\t\t\t\t\t\t<a href=\"#tabs_desc_1341_3\" aria-controls=\"tabs_desc_1341_3\" role=\"tab\" data-toggle=\"tab\">\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-code\"><\/i> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t<span>Java<\/span>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t<\/a>\r\n\t\t\t\t\t\t\t<\/li>\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t<li role=\"presentation\"  onclick=\"do_resize()\">\r\n\t\t\t\t\t\t\t\t<a href=\"#tabs_desc_1341_4\" aria-controls=\"tabs_desc_1341_4\" role=\"tab\" data-toggle=\"tab\">\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-code\"><\/i> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t<span>Python<\/span>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t<\/a>\r\n\t\t\t\t\t\t\t<\/li>\r\n\t\t\t\t\t\t\t\t\t\t\t <\/ul>\r\n\r\n\t\t\t\t\t  <!-- Tab panes -->\r\n\t\t\t\t\t  <div class=\"tab-content\" id=\"tab-content_1341\">\r\n\t\t\t\t\t\t\t\t\t\t\t\t <div role=\"tabpanel\" class=\"tab-pane  in active \" id=\"tabs_desc_1341_1\">\r\n\t\t\t\t\t\t\t\t<!-- wp:enlighter\/codeblock {\"language\":\"c\"} -->\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\r\n#include&lt;stdio.h&gt;\r\n#include&lt;string.h&gt;\r\nint main() \r\n{ \r\n  int test;\r\n  scanf(&quot;%d&quot;,&amp;test);\r\n  while(test--){\r\n    char str[1000000], pat[1000000];\r\n    scanf(&quot;%s%s&quot;,str,pat);\r\n\r\n    int len1 = strlen(str); \r\n    int len2 = strlen(pat); \r\n\r\n    if (len1 &lt; len2) \r\n    { \r\n        printf(&quot;Not Found&#92;n&quot;); \r\n    }else{ \r\n        int hash_pat[256] = {0}; \r\n        int hash_str[256] = {0}; \r\n\r\n        for (int i = 0; i &lt; len2; i++) \r\n            hash_pat[pat[i]]++; \r\n\r\n        int start = 0, start_index = -1, min_len = 9999999; \r\n\r\n        int count = 0; \r\n        for (int j = 0; j &lt; len1 ; j++) \r\n        { \r\n            hash_str[str[j]]++; \r\n\r\n            if (hash_pat[str[j]] != 0 &amp;&amp; \r\n                hash_str[str[j]] &lt;= hash_pat[str[j]] ) \r\n                count++; \r\n\r\n            if (count == len2) \r\n            { \r\n                while ( hash_str[str[start]] &gt; hash_pat[str[start]] \r\n                    || hash_pat[str[start]] == 0) \r\n                { \r\n\r\n                    if (hash_str[str[start]] &gt; hash_pat[str[start]]) \r\n                        hash_str[str[start]]--; \r\n                    start++; \r\n                } \r\n\r\n                int len_window = j - start + 1; \r\n                if (min_len &gt; len_window) \r\n                { \r\n                    min_len = len_window; \r\n                    start_index = start; \r\n                } \r\n            } \r\n        } \r\n\r\n        if (start_index == -1)\r\n          printf(&quot;Not Found&#92;n&quot;); \r\n        else{\r\n          for(int i=start_index; i&lt;min_len+start_index; i++)\r\n            printf(&quot;%c&quot;,str[i]);\r\n          printf(&quot;&#92;n&quot;);\r\n          }\r\n    }\r\n    }\r\n} \r\n<\/pre>\r\n<!-- \/wp:enlighter\/codeblock -->\r\n\t\t\t\t\t\t <\/div>\r\n\t\t\t\t\t\t\t\t\t\t\t\t <div role=\"tabpanel\" class=\"tab-pane \" id=\"tabs_desc_1341_2\">\r\n\t\t\t\t\t\t\t\t<!-- wp:enlighter\/codeblock {\"language\":\"cpp\"} -->\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"cpp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\r\n#include&lt;bits\/stdc++.h&gt; \r\nusing namespace std; \r\n\r\nconst int no_of_chars = 256; \r\n\r\nint main() \r\n{ \r\n  int test;\r\n  cin&gt;&gt;test;\r\n  while(test--){\r\n    string str, pat;\r\n    cin&gt;&gt;str&gt;&gt;pat;\r\n\r\n    int len1 = str.length(); \r\n    int len2 = pat.length(); \r\n\r\n    if (len1 &lt; len2) \r\n    { \r\n        cout &lt;&lt; &quot;Not Found&#92;n&quot;; \r\n    }else{ \r\n\r\n        int hash_pat[no_of_chars] = {0}; \r\n        int hash_str[no_of_chars] = {0}; \r\n\r\n        for (int i = 0; i &lt; len2; i++) \r\n            hash_pat[pat[i]]++; \r\n\r\n        int start = 0, start_index = -1, min_len = INT_MAX; \r\n\r\n        int count = 0; \r\n        for (int j = 0; j &lt; len1 ; j++) \r\n        { \r\n            hash_str[str[j]]++; \r\n\r\n            if (hash_pat[str[j]] != 0 &amp;&amp; \r\n                hash_str[str[j]] &lt;= hash_pat[str[j]] ) \r\n                count++; \r\n\r\n            if (count == len2) \r\n            { \r\n                while ( hash_str[str[start]] &gt; hash_pat[str[start]] \r\n                    || hash_pat[str[start]] == 0) \r\n                { \r\n\r\n                    if (hash_str[str[start]] &gt; hash_pat[str[start]]) \r\n                        hash_str[str[start]]--; \r\n                    start++; \r\n                } \r\n\r\n                int len_window = j - start + 1; \r\n                if (min_len &gt; len_window) \r\n                { \r\n                    min_len = len_window; \r\n                    start_index = start; \r\n                } \r\n            } \r\n        } \r\n\r\n        if (start_index == -1)\r\n          cout&lt;&lt;&quot;Not Found&#92;n&quot;; \r\n        else{\r\n          for(int i=start_index; i&lt;min_len+start_index; i++)\r\n            cout&lt;&lt;str[i];\r\n          cout&lt;&lt;endl;\r\n          }\r\n    }\r\n    }\r\n} \r\n<\/pre>\r\n<!-- \/wp:enlighter\/codeblock -->\r\n\t\t\t\t\t\t <\/div>\r\n\t\t\t\t\t\t\t\t\t\t\t\t <div role=\"tabpanel\" class=\"tab-pane \" id=\"tabs_desc_1341_3\">\r\n\t\t\t\t\t\t\t\t<!-- wp:enlighter\/codeblock {\"language\":\"java\"} -->\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\r\nimport java.util.*;\r\nimport java.io.*;\r\nimport java.lang.Math;\r\n \r\npublic class Main {\r\npublic static void main(String args[]) throws IOException {\r\n \r\n    Scanner sc= new Scanner(System.in);\r\n    int test = sc.nextInt();\r\n    while(test != 0){\r\n \r\n        String str = sc.next();\r\n        String pat= sc.next();\r\n \r\n        int len1 = str.length(); \r\n        int len2 = pat.length(); \r\n \r\n        if (len1 &lt; len2) \r\n        { \r\n            System.out.println(&quot;Not Found&quot;); \r\n        }else{ \r\n \r\n            int hash_pat[] = new int[256]; \r\n            int hash_str[] = new int[256]; \r\n \r\n            for (int i = 0; i &lt; len2; i++) \r\n                hash_pat[pat.charAt(i) - 'a']++; \r\n \r\n            int start = 0, start_index = -1, min_len = 9999999; \r\n \r\n            int count = 0; \r\n            for (int j = 0; j &lt; len1 ; j++) \r\n            { \r\n                hash_str[str.charAt(j) - 'a']++; \r\n \r\n                if (hash_pat[str.charAt(j) - 'a'] != 0 &amp;&amp; \r\n                    hash_str[str.charAt(j) - 'a'] &lt;= hash_pat[str.charAt(j) - 'a'] ) \r\n                    count++; \r\n \r\n                if (count == len2) \r\n                { \r\n                    while ( hash_str[str.charAt(start) - 'a'] &gt; hash_pat[str.charAt(start) - 'a'] \r\n                        || hash_pat[str.charAt(start) - 'a'] == 0) \r\n                    { \r\n \r\n                        if (hash_str[str.charAt(start) - 'a'] &gt; hash_pat[str.charAt(start) - 'a']) \r\n                            hash_str[str.charAt(start) - 'a']--; \r\n                        start++; \r\n                    } \r\n \r\n                    int len_window = j - start + 1; \r\n                    if (min_len &gt; len_window) \r\n                    { \r\n                        min_len = len_window; \r\n                        start_index = start; \r\n                    } \r\n                } \r\n            } \r\n \r\n            if (start_index == -1)\r\n              System.out.println(&quot;Not Found&quot;); \r\n            else{\r\n              for(int i=start_index; i&lt;min_len+start_index; i++)\r\n                System.out.print(str.charAt(i));\r\n              System.out.println();\r\n              }\r\n        }\r\n \r\n        test--;\r\n    }\r\n  }\r\n}\r\n<\/pre>\r\n<!-- \/wp:enlighter\/codeblock -->\r\n\t\t\t\t\t\t <\/div>\r\n\t\t\t\t\t\t\t\t\t\t\t\t <div role=\"tabpanel\" class=\"tab-pane \" id=\"tabs_desc_1341_4\">\r\n\t\t\t\t\t\t\t\t<!-- wp:enlighter\/codeblock {\"language\":\"Python\"} -->\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"Python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\r\nno_of_chars = 256\r\n \r\nfor _ in range(int(input())):\r\n \r\n\ts, pat = input().split()\r\n\tlen1, len2 = len(s), len(pat)\r\n\tif len1 < len2:\r\n\t\tprint(\"Not Found\")\r\n\telse:\r\n \r\n\t\thash_pat = [0] * no_of_chars \r\n\t\thash_s = [0] * no_of_chars \r\n \r\n\t\tfor i in range(len2): \r\n\t\t\thash_pat[ord(pat[i])] += 1 \r\n \r\n\t\tstart = 0\r\n\t\tstart_index = -1\r\n\t\tmin_len = float(\"inf\")\r\n\t\tcount = 0\r\n \r\n\t\tfor j in range(len1): \r\n \r\n\t\t\thash_s[ord(s[j])] += 1\r\n \r\n\t\t\tif (hash_pat[ord(s[j])] != 0 and hash_s[ord(s[j])] <= hash_pat[ord(s[j])] ):\r\n\t\t\t\tcount += 1 \r\n \r\n\t\t\tif (count == len2): \r\n \r\n\t\t\t\twhile ( hash_s[ord(s[start])] > hash_pat[ord(s[start])] or hash_pat[ord(s[start])] == 0): \r\n \r\n\t\t\t\t\tif (hash_s[ord(s[start])] > hash_pat[ord(s[start])]): \r\n\t\t\t\t\t\thash_s[ord(s[start])] -= 1 \r\n \r\n\t\t\t\t\tstart += 1 \r\n \r\n\t\t\t\tlen_window = j - start + 1; \r\n \r\n\t\t\t\tif (min_len > len_window): \r\n \r\n\t\t\t\t\tmin_len = len_window \r\n\t\t\t\t\tstart_index = start \r\n \r\n\t\tif (start_index == -1):\r\n\t\t\tprint(\"Not Found\")\r\n \r\n\t\telse:\r\n \r\n\t\t\tfor i in range(start_index, min_len+start_index):\r\n\t\t\t\tprint(s[i], end=\"\")\r\n\t\t\tprint()\r\n\r\n<\/pre>\r\n<!-- \/wp:enlighter\/codeblock -->\t\t\t\t\t\t <\/div>\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t <\/div>\r\n\t\t\t\t\t \r\n\t\t\t\t <\/div>\r\n <script>\r\n\t\tjQuery(function () {\r\n\t\t\tjQuery('#myTab_1341 a:first').tab('show')\r\n\t\t});\r\n\t\t\r\n\t\t\t\tjQuery(function(){\r\n\t\t\tvar b=\"fadeIn\";\r\n\t\t\tvar c;\r\n\t\t\tvar a;\r\n\t\t\td(jQuery(\"#myTab_1341 a\"),jQuery(\"#tab-content_1341\"));function d(e,f,g){\r\n\t\t\t\te.click(function(i){\r\n\t\t\t\t\ti.preventDefault();\r\n\t\t\t\t\tjQuery(this).tab(\"show\");\r\n\t\t\t\t\tvar h=jQuery(this).data(\"easein\");\r\n\t\t\t\t\tif(c){c.removeClass(a);}\r\n\t\t\t\t\tif(h){f.find(\"div.active\").addClass(\"animated \"+h);a=h;}\r\n\t\t\t\t\telse{if(g){f.find(\"div.active\").addClass(\"animated \"+g);a=g;}else{f.find(\"div.active\").addClass(\"animated \"+b);a=b;}}c=f.find(\"div.active\");\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t});\r\n\t\t\r\n\r\n\t\tfunction do_resize(){\r\n\r\n\t\t\tvar width=jQuery( '.tab-content .tab-pane iframe' ).width();\r\n\t\t\tvar height=jQuery( '.tab-content .tab-pane iframe' ).height();\r\n\r\n\t\t\tvar toggleSize = true;\r\n\t\t\tjQuery('iframe').animate({\r\n\t\t\t    width: toggleSize ? width : 640,\r\n\t\t\t    height: toggleSize ? height : 360\r\n\t\t\t  }, 250);\r\n\r\n\t\t\t  toggleSize = !toggleSize;\r\n\t\t}\r\n\r\n\r\n\t<\/script>\r\n\t\t\t\t\r\n\t\t\t<br \/>\n<strong>Space Complexity<\/strong>  of this approach would be <code>O(1).<\/code><\/p>\n<p>[forminator_quiz id=&quot;1349&quot;]<\/p>\n<p>This article tried to discuss the concept of <strong>Strings, Hashing<\/strong>. Hope this blog helps you understand and solve the problem. To practice more problems on Strings, Hashing you can check out <a href=\"#\"><\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Find the minimum size of the substring of string S which contains all the character from a given string T. Print the substring with minimum length. Test Case Input: 1 prepbytes pyte ccbabcab bbab Output: pbyte babcab Explanation: Case 1: All characters in string &#8216;pyte&#8217; are present in &#8216;pbyte&#8217; and this is the smallest substring. [&hellip;]<\/p>\n","protected":false},"author":52,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[76],"tags":[96,82,65,98,56],"class_list":["post-1338","post","type-post","status-publish","format-standard","hentry","category-strings-interview-questions","tag-coding","tag-hard","tag-interview","tag-preparation","tag-strings"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Minimum Window Substring : Problem, Solution and Code<\/title>\n<meta name=\"description\" content=\"Find the Minimum Size of the Substring of String S Which Contains All the Character from a Given String T. Print the Substring With Minimum Length.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/prepbytes.com\/blog\/minimum-window-substring\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Minimum Window Substring : Problem, Solution and Code\" \/>\n<meta property=\"og:description\" content=\"Find the Minimum Size of the Substring of String S Which Contains All the Character from a Given String T. Print the Substring With Minimum Length.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/prepbytes.com\/blog\/minimum-window-substring\/\" \/>\n<meta property=\"og:site_name\" content=\"PrepBytes Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prepbytes0211\/\" \/>\n<meta property=\"article:published_time\" content=\"2020-06-10T19:09:36+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-11-18T12:16:19+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645179916103-Article_411.png\" \/>\n<meta name=\"author\" content=\"Prepbytes\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Prepbytes\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/prepbytes.com\/blog\/minimum-window-substring\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/minimum-window-substring\/\"},\"author\":{\"name\":\"Prepbytes\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e\"},\"headline\":\"Minimum Window Substring\",\"datePublished\":\"2020-06-10T19:09:36+00:00\",\"dateModified\":\"2022-11-18T12:16:19+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/minimum-window-substring\/\"},\"wordCount\":788,\"commentCount\":0,\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/minimum-window-substring\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645179916103-Article_411.png\",\"keywords\":[\"coding\",\"hard\",\"interview\",\"preparation\",\"Strings\"],\"articleSection\":[\"Strings Interview Questions\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/prepbytes.com\/blog\/minimum-window-substring\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/prepbytes.com\/blog\/minimum-window-substring\/\",\"url\":\"https:\/\/prepbytes.com\/blog\/minimum-window-substring\/\",\"name\":\"Minimum Window Substring : Problem, Solution and Code\",\"isPartOf\":{\"@id\":\"http:\/\/43.205.93.38\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/minimum-window-substring\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/minimum-window-substring\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645179916103-Article_411.png\",\"datePublished\":\"2020-06-10T19:09:36+00:00\",\"dateModified\":\"2022-11-18T12:16:19+00:00\",\"description\":\"Find the Minimum Size of the Substring of String S Which Contains All the Character from a Given String T. Print the Substring With Minimum Length.\",\"breadcrumb\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/minimum-window-substring\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/prepbytes.com\/blog\/minimum-window-substring\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prepbytes.com\/blog\/minimum-window-substring\/#primaryimage\",\"url\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645179916103-Article_411.png\",\"contentUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645179916103-Article_411.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/prepbytes.com\/blog\/minimum-window-substring\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/43.205.93.38\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Strings Interview Questions\",\"item\":\"https:\/\/prepbytes.com\/blog\/category\/strings-interview-questions\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Minimum Window Substring\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/43.205.93.38\/#website\",\"url\":\"http:\/\/43.205.93.38\/\",\"name\":\"PrepBytes Blog\",\"description\":\"ONE-STOP RESOURCE FOR EVERYTHING RELATED TO CODING\",\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/43.205.93.38\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"http:\/\/43.205.93.38\/#organization\",\"name\":\"Prepbytes\",\"url\":\"http:\/\/43.205.93.38\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp\",\"contentUrl\":\"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp\",\"width\":160,\"height\":160,\"caption\":\"Prepbytes\"},\"image\":{\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/prepbytes0211\/\",\"https:\/\/www.instagram.com\/prepbytes\/\",\"https:\/\/www.linkedin.com\/company\/prepbytes\/\",\"https:\/\/www.youtube.com\/channel\/UC0xGnHDrjUM1pDEK2Ka5imA\"]},{\"@type\":\"Person\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e\",\"name\":\"Prepbytes\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g\",\"caption\":\"Prepbytes\"},\"url\":\"https:\/\/prepbytes.com\/blog\/author\/gourav-jaincollegedekho-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Minimum Window Substring : Problem, Solution and Code","description":"Find the Minimum Size of the Substring of String S Which Contains All the Character from a Given String T. Print the Substring With Minimum Length.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/prepbytes.com\/blog\/minimum-window-substring\/","og_locale":"en_US","og_type":"article","og_title":"Minimum Window Substring : Problem, Solution and Code","og_description":"Find the Minimum Size of the Substring of String S Which Contains All the Character from a Given String T. Print the Substring With Minimum Length.","og_url":"https:\/\/prepbytes.com\/blog\/minimum-window-substring\/","og_site_name":"PrepBytes Blog","article_publisher":"https:\/\/www.facebook.com\/prepbytes0211\/","article_published_time":"2020-06-10T19:09:36+00:00","article_modified_time":"2022-11-18T12:16:19+00:00","og_image":[{"url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645179916103-Article_411.png","type":"","width":"","height":""}],"author":"Prepbytes","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Prepbytes","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/prepbytes.com\/blog\/minimum-window-substring\/#article","isPartOf":{"@id":"https:\/\/prepbytes.com\/blog\/minimum-window-substring\/"},"author":{"name":"Prepbytes","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e"},"headline":"Minimum Window Substring","datePublished":"2020-06-10T19:09:36+00:00","dateModified":"2022-11-18T12:16:19+00:00","mainEntityOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/minimum-window-substring\/"},"wordCount":788,"commentCount":0,"publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/minimum-window-substring\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645179916103-Article_411.png","keywords":["coding","hard","interview","preparation","Strings"],"articleSection":["Strings Interview Questions"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/prepbytes.com\/blog\/minimum-window-substring\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/prepbytes.com\/blog\/minimum-window-substring\/","url":"https:\/\/prepbytes.com\/blog\/minimum-window-substring\/","name":"Minimum Window Substring : Problem, Solution and Code","isPartOf":{"@id":"http:\/\/43.205.93.38\/#website"},"primaryImageOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/minimum-window-substring\/#primaryimage"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/minimum-window-substring\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645179916103-Article_411.png","datePublished":"2020-06-10T19:09:36+00:00","dateModified":"2022-11-18T12:16:19+00:00","description":"Find the Minimum Size of the Substring of String S Which Contains All the Character from a Given String T. Print the Substring With Minimum Length.","breadcrumb":{"@id":"https:\/\/prepbytes.com\/blog\/minimum-window-substring\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/prepbytes.com\/blog\/minimum-window-substring\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prepbytes.com\/blog\/minimum-window-substring\/#primaryimage","url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645179916103-Article_411.png","contentUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645179916103-Article_411.png"},{"@type":"BreadcrumbList","@id":"https:\/\/prepbytes.com\/blog\/minimum-window-substring\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/43.205.93.38\/"},{"@type":"ListItem","position":2,"name":"Strings Interview Questions","item":"https:\/\/prepbytes.com\/blog\/category\/strings-interview-questions\/"},{"@type":"ListItem","position":3,"name":"Minimum Window Substring"}]},{"@type":"WebSite","@id":"http:\/\/43.205.93.38\/#website","url":"http:\/\/43.205.93.38\/","name":"PrepBytes Blog","description":"ONE-STOP RESOURCE FOR EVERYTHING RELATED TO CODING","publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/43.205.93.38\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"http:\/\/43.205.93.38\/#organization","name":"Prepbytes","url":"http:\/\/43.205.93.38\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/","url":"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp","contentUrl":"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp","width":160,"height":160,"caption":"Prepbytes"},"image":{"@id":"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/prepbytes0211\/","https:\/\/www.instagram.com\/prepbytes\/","https:\/\/www.linkedin.com\/company\/prepbytes\/","https:\/\/www.youtube.com\/channel\/UC0xGnHDrjUM1pDEK2Ka5imA"]},{"@type":"Person","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e","name":"Prepbytes","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g","caption":"Prepbytes"},"url":"https:\/\/prepbytes.com\/blog\/author\/gourav-jaincollegedekho-com\/"}]}},"_links":{"self":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/1338","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/users\/52"}],"replies":[{"embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/comments?post=1338"}],"version-history":[{"count":9,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/1338\/revisions"}],"predecessor-version":[{"id":10626,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/1338\/revisions\/10626"}],"wp:attachment":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/media?parent=1338"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/categories?post=1338"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/tags?post=1338"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}