Skip to content

Commit edea392

Browse files
Rishabh JainRishabh Jain
authored andcommitted
update 3._Longest_Substring_Without_Repeating_Characters.md
1 parent 6d1b095 commit edea392

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
### 3. Longest Substring Without Repeating Characters
3+
4+
题目:
5+
https://leetcode.com/problems/longest-substring-without-repeating-characters/
6+
7+
难度:
8+
Medium
9+
10+
```java
11+
class Solution {
12+
public int lengthOfLongestSubstring(String s) {
13+
int stIdx = 0, maxLen = 0;
14+
int arr[] = new int[128];
15+
for(int i=0;i<s.length();i++){
16+
stIdx = Math.max(arr[s.charAt(i)],stIdx);
17+
maxLen = Math.max(maxLen, i-stIdx+1);
18+
arr[s.charAt(i)] = i+1;
19+
}
20+
return maxLen;
21+
}
22+
}
23+
```java

0 commit comments

Comments
 (0)