Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 60e3fc9

Browse files
committed
upd: Longest Substring Without Repeating Characters
1 parent e55cd74 commit 60e3fc9

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

‎README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ LeetCode JavaScript Solution
88
| Baseball Game | Easy | 2017年10月10日 |
99
| Map Sum Pairs | Medium | 2017年10月10日 |
1010
| Add Two Numbers | Medium | 2017年10月10日 |
11-
| Length Of Last Word | Easy | 2017年10月10日 |
11+
| Length Of Last Word | Easy | 2017年10月10日 |
12+
| Longest Substring Without Repeating Characters | Medium | 2017年10月11日 |
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* @param {string} s
3+
* @return {number}
4+
*/
5+
var lengthOfLongestSubstring = function(s) {
6+
var temp = {}, max = 0;
7+
for (var i = 0, j = 0; j < s.length; ++j) {
8+
if (temp[s[j]]) {
9+
i = Math.max(i, temp[s[j]]);
10+
}
11+
max = Math.max(max, j - i + 1);
12+
temp[s[j]] = j + 1;
13+
}
14+
return max;
15+
};

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /