Skip to content

Commit c137930

Browse files
committed
fix(book/hashmap): exercise example and add tests
1 parent 65b6edd commit c137930

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

book/content/part02/hash-map.asc

+1-1
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ function longestSubstring(s) {
486486
.Examples
487487
[source, javascript]
488488
----
489-
longestSubstring('abcdaefg'); // 4 ('abcd' or 'aefg')
489+
longestSubstring('abcdaefg'); // 7 ('bcdaefg')
490490
longestSubstring('abbaa'); // 2 ('ab')
491491
longestSubstring('abbadvdf') // 4 ('badv')
492492
----

book/interview-questions/longest-substring-without-repeating-characters.spec.js

+6
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,11 @@ const { lenLongestSubstring } = require('./longest-substring-without-repeating-c
2020
const expected = 5;
2121
expect(fn(actual)).toEqual(expected);
2222
});
23+
24+
it('should work with example', () => {
25+
const actual = 'abcdaefg';
26+
const expected = 7;
27+
expect(fn(actual)).toEqual(expected);
28+
});
2329
});
2430
});

0 commit comments

Comments
 (0)