Skip to content

Commit cdd47aa

Browse files
committed
longest substring with non repeating chars array instead of hash map
1 parent 36afaeb commit cdd47aa

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/dymanicProgramming/LongestSubstringWithoutRepChars.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public static void main(String[] ss) {
2424
List<String> strings1 = new ArrayList<String>();
2525
map[s.charAt(0)]=0;
2626
for (int k = 1; k < s.length(); k++) {
27-
if (map[s.charAt(k)]< k && map[s.charAt(k)] > start) {
27+
if (map[s.charAt(k)] >= start) {
2828
if (k - start >= length) {
2929
length = k - start;
3030
Iterator<String> stringIterator = strings1.iterator();
@@ -38,6 +38,7 @@ public static void main(String[] ss) {
3838
}
3939
int num = map[s.charAt(k)];
4040
start = num + 1;
41+
4142
}
4243
map[s.charAt(k)]=k;
4344
}

0 commit comments

Comments
 (0)