Skip to content

Commit 64137f5

Browse files
committed
Added minimum window substring implementation and test file with prettier code
1 parent 8661dd3 commit 64137f5

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

Maths/MobiusFunction.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ export const mobiusFunction = (number) => {
2828
return primeFactorsArray.length !== new Set(primeFactorsArray).size
2929
? 0
3030
: primeFactorsArray.length % 2 === 0
31-
? 1
32-
: -1
31+
? 1
32+
: -1
3333
}

Sliding-Windows/MinimumWindowSubstring.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
function minWindowSubstring(s, t) {
8-
if (t.length > s.length) return ""
8+
if (t.length > s.length) return ''
99

1010
const need = {}
1111
for (let char of t) {
@@ -36,7 +36,7 @@ function minWindowSubstring(s, t) {
3636
}
3737
}
3838

39-
return minLen === Infinity ? "" : s.substring(minStart, minStart + minLen)
39+
return minLen === Infinity ? '' : s.substring(minStart, minStart + minLen)
4040
}
4141

4242
export { minWindowSubstring }

Sliding-Windows/test/MinimumWindowSubstring.test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
* Test file for Minimum Window Substring
33
*/
44

5-
import { minWindowSubstring } from "../MinimumWindowSubstring.js"
5+
import { minWindowSubstring } from '../MinimumWindowSubstring.js'
66

7-
test("return smallest window containing all characters", () => {
8-
expect(minWindowSubstring("ADOBECODEBANC", "ABC")).toBe("BANC")
7+
test('return smallest window containing all characters', () => {
8+
expect(minWindowSubstring('ADOBECODEBANC', 'ABC')).toBe('BANC')
99
})
1010

11-
test("return empty string if no window found", () => {
12-
expect(minWindowSubstring("HELLO", "XYZ")).toBe("")
11+
test('return empty string if no window found', () => {
12+
expect(minWindowSubstring('HELLO', 'XYZ')).toBe('')
1313
})
1414

15-
test("return full string if it matches exactly", () => {
16-
expect(minWindowSubstring("ABC", "ABC")).toBe("ABC")
15+
test('return full string if it matches exactly', () => {
16+
expect(minWindowSubstring('ABC', 'ABC')).toBe('ABC')
1717
})

0 commit comments

Comments
 (0)