From fdde41dc330dcaa851910f796e4422eee29bf963 Mon Sep 17 00:00:00 2001 From: Jagannath8 <64650848+Jagannath8@users.noreply.github.com> Date: Tue, 8 Jun 2021 20:08:05 +0530 Subject: [PATCH 1/4] Longest Substring --- Code/Java/Longest Substring | 46 +++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 Code/Java/Longest Substring diff --git a/Code/Java/Longest Substring b/Code/Java/Longest Substring new file mode 100644 index 000000000..c89df45f2 --- /dev/null +++ b/Code/Java/Longest Substring @@ -0,0 +1,46 @@ +Question + +Given a string s, find the length of the longest substring without repeating characters. + +Example 1: + +Input: s = "abcabcbb" +Output: 3 +Explanation: The answer is "abc", with the length of 3. +Example 2: + +Input: s = "bbbbb" +Output: 1 +Explanation: The answer is "b", with the length of 1. +Example 3: + +Input: s = "pwwkew" +Output: 3 +Explanation: The answer is "wke", with the length of 3. +Notice that the answer must be a substring, "pwke" is a subsequence and not a substring. +Example 4: + +Input: s = "" +Output: 0 + +***************************************************************************************************** + + +Solution + +public class Longest Substring { + public int lengthOfLongestSubstring(String s) { + int len = s.length(); + int ans=0; + Map map = new HashMap<>(); + for(int j=0, i=0; j Date: Tue, 8 Jun 2021 20:27:57 +0530 Subject: [PATCH 2/4] Longest_Substring --- Code/Java/Longest Substring | 46 ------------------------------- Code/Java/Longest_Substring.java | 47 ++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 46 deletions(-) delete mode 100644 Code/Java/Longest Substring create mode 100644 Code/Java/Longest_Substring.java diff --git a/Code/Java/Longest Substring b/Code/Java/Longest Substring deleted file mode 100644 index c89df45f2..000000000 --- a/Code/Java/Longest Substring +++ /dev/null @@ -1,46 +0,0 @@ -Question - -Given a string s, find the length of the longest substring without repeating characters. - -Example 1: - -Input: s = "abcabcbb" -Output: 3 -Explanation: The answer is "abc", with the length of 3. -Example 2: - -Input: s = "bbbbb" -Output: 1 -Explanation: The answer is "b", with the length of 1. -Example 3: - -Input: s = "pwwkew" -Output: 3 -Explanation: The answer is "wke", with the length of 3. -Notice that the answer must be a substring, "pwke" is a subsequence and not a substring. -Example 4: - -Input: s = "" -Output: 0 - -***************************************************************************************************** - - -Solution - -public class Longest Substring { - public int lengthOfLongestSubstring(String s) { - int len = s.length(); - int ans=0; - Map map = new HashMap<>(); - for(int j=0, i=0; j map = new HashMap<>(); + for(int j=0, i=0; j Date: Tue, 8 Jun 2021 20:30:10 +0530 Subject: [PATCH 3/4] new file added --- 2D_Array/readme.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/2D_Array/readme.md b/2D_Array/readme.md index 74f031c3a..5461a4e30 100644 --- a/2D_Array/readme.md +++ b/2D_Array/readme.md @@ -20,5 +20,6 @@ Due to the fact that the elements of 2D arrays can be random accessed. Similar t * Spiral Print ----> [C++](/Code/C++/spiral_print.cpp) * Staircase Search ----> [C++](/Code/C++/staircase_search.cpp) * Substraction of two Matrices ----> [Java](/Code/Java/matrixop_sub.java) -* Transpose of a Matrix --->[Java](/Code/Java/transpose.java) | [Python](/Code/Python/Transpose_of_matrix.py) +* Transpose of a Matrix --->[Java](/Code/Java/transpose.java) | [](/Code//Transpose_of_matrix.py) * Wave Print ----> [C++](/Code/C++/wave_print.cpp) +* Longest Substring Without Repeating Characters ----> [Java](/Code/Java/Longest_Substring.java) From 4e5a8aa99e82681601566b07b07b4faafe2b488c Mon Sep 17 00:00:00 2001 From: Jagannath8 <64650848+Jagannath8@users.noreply.github.com> Date: Tue, 8 Jun 2021 20:32:19 +0530 Subject: [PATCH 4/4] new change --- 2D_Array/readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2D_Array/readme.md b/2D_Array/readme.md index 5461a4e30..5aa604c3f 100644 --- a/2D_Array/readme.md +++ b/2D_Array/readme.md @@ -13,6 +13,7 @@ Due to the fact that the elements of 2D arrays can be random accessed. Similar t * Checking Teoplitz Matrix Algorithm ----> [Java](/Code/Java/Toeplitz.java) * Clockwise Rotation ----> [C++](/Code/C++/2d_matrix_rotation_90degree_clockwise.cpp) * Inverse of a Matrix ----> [Java](/Code/Java/matrixop_inverse.java) +* Longest Substring Without Repeating Characters ----> [Java](/Code/Java/Longest_Substring.java) * Matrix Operations ----> [C++](/Code/C++/matrix_operations.cpp) * Multiplication of two Matrices ----> [Java](/Code/Java/matrixop_mul.java) * Overall Median of Matrix ---> [Java](/Code/Java/overall_median_matrix.java) @@ -22,4 +23,3 @@ Due to the fact that the elements of 2D arrays can be random accessed. Similar t * Substraction of two Matrices ----> [Java](/Code/Java/matrixop_sub.java) * Transpose of a Matrix --->[Java](/Code/Java/transpose.java) | [](/Code//Transpose_of_matrix.py) * Wave Print ----> [C++](/Code/C++/wave_print.cpp) -* Longest Substring Without Repeating Characters ----> [Java](/Code/Java/Longest_Substring.java)