[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"searchBlogPosts":3,"$fEQh-HK2K9kQilKZ7xCgkBxez_dRehuB2kLl4FCLHUfQ":7},[4],{"_path":5,"title":6},"\u002Fblog\u002F2023\u002F09\u002F17\u002Fspring-boot-postgresql","Spring Boot with PostgreSQL & pgAdmin in Docker",{"title":8,"category":9,"problemHtml":10,"solutions":11,"repoUrl":16},"Longest Substring Without Repeating Characters","LeetCode","\u003Cp class=\"difficulty Medium\">Medium\u003C\u002Fp>\u003Chr>\u003Cp>Given a string \u003Ccode>s\u003C\u002Fcode>, find the length of the \u003Cstrong>longest\u003C\u002Fstrong> \u003Cspan data-keyword=\"substring-nonempty\">\u003Cstrong>substring\u003C\u002Fstrong>\u003C\u002Fspan> without duplicate characters.\u003C\u002Fp>\n\n\u003Cp>&nbsp;\u003C\u002Fp>\n\u003Cp>\u003Cstrong class=\"example\">Example 1:\u003C\u002Fstrong>\u003C\u002Fp>\n\n\u003Cpre>\n\u003Cstrong>Input:\u003C\u002Fstrong> s = &quot;abcabcbb&quot;\n\u003Cstrong>Output:\u003C\u002Fstrong> 3\n\u003Cstrong>Explanation:\u003C\u002Fstrong> The answer is &quot;abc&quot;, with the length of 3. Note that \u003Ccode>&quot;bca&quot;\u003C\u002Fcode> and \u003Ccode>&quot;cab&quot;\u003C\u002Fcode> are also correct answers.\n\u003C\u002Fpre>\n\n\u003Cp>\u003Cstrong class=\"example\">Example 2:\u003C\u002Fstrong>\u003C\u002Fp>\n\n\u003Cpre>\n\u003Cstrong>Input:\u003C\u002Fstrong> s = &quot;bbbbb&quot;\n\u003Cstrong>Output:\u003C\u002Fstrong> 1\n\u003Cstrong>Explanation:\u003C\u002Fstrong> The answer is &quot;b&quot;, with the length of 1.\n\u003C\u002Fpre>\n\n\u003Cp>\u003Cstrong class=\"example\">Example 3:\u003C\u002Fstrong>\u003C\u002Fp>\n\n\u003Cpre>\n\u003Cstrong>Input:\u003C\u002Fstrong> s = &quot;pwwkew&quot;\n\u003Cstrong>Output:\u003C\u002Fstrong> 3\n\u003Cstrong>Explanation:\u003C\u002Fstrong> The answer is &quot;wke&quot;, with the length of 3.\nNotice that the answer must be a substring, &quot;pwke&quot; is a subsequence and not a substring.\n\u003C\u002Fpre>\n\n\u003Cp>&nbsp;\u003C\u002Fp>\n\u003Cp>\u003Cstrong>Constraints:\u003C\u002Fstrong>\u003C\u002Fp>\n\n\u003Cul>\n\t\u003Cli>\u003Ccode>0 &lt;= s.length &lt;= 5 * 10\u003Csup>4\u003C\u002Fsup>\u003C\u002Fcode>\u003C\u002Fli>\n\t\u003Cli>\u003Ccode>s\u003C\u002Fcode> consists of English letters, digits, symbols and spaces.\u003C\u002Fli>\n\u003C\u002Ful>",[12],{"lang":13,"label":14,"html":15},"java","Java","\u003Cpre>\u003Ccode class=\"language-java\">class Solution {\n    public int lengthOfLongestSubstring(String s) {\n             \n        int maxLen = 0, n = s.length();\n\n        if( n == 0|| n == 1) return n;\n\n        for(int i = 0; i &lt; n-1;i++){\n            int len = 1 ;\n            Set&lt;Character&gt; set = new HashSet&lt;&gt;();\n            set.add(s.charAt(i));\n            for(int j = i+1; j &lt; n; j++){\n                if(set.contains(s.charAt(j))){\n                    set = new HashSet&lt;&gt;();\n                    break;\n                }\n                set.add(s.charAt(j));\n                len++;\n            }\n            \n            \n            maxLen = Math.max(maxLen, len);\n        }\n        \n        return maxLen;\n    }\n}\u003C\u002Fcode>\u003C\u002Fpre>","https:\u002F\u002Fgithub.com\u002Fvishwarajsali\u002FInterviewPrep\u002Ftree\u002Fmain\u002F0003-longest-substring-without-repeating-characters"]