Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
4e38ab5
fix: #758 optimised armstrongNumber code
developerr-ayush Sep 30, 2023
f8f0e2a
Merge branch 'master' of https://github.com/developerr-ayush/JavaScript
developerr-ayush Oct 1, 2023
184ae84
fix:#758 Average Median code optimised
developerr-ayush Oct 1, 2023
b8be2f9
feat: TwoSum function added with test cases
developerr-ayush Oct 1, 2023
882db43
revert code
developerr-ayush Oct 1, 2023
c58f28f
Fix: #758 used ternary operator to make code more optimised
developerr-ayush Oct 1, 2023
bdf8ed8
Feat: TwoSum function created with test cases
developerr-ayush Oct 2, 2023
8bde9b9
Feat: TwoSum function created with test cases
developerr-ayush Oct 2, 2023
a254b86
Merge branch 'TheAlgorithms:master' into master
developerr-ayush Oct 2, 2023
97e147c
Merge branch 'TheAlgorithms:master' into Feature-TwoSum-function
developerr-ayush Oct 2, 2023
01539b5
Merge pull request #1 from developerr-ayush/Feature-TwoSum-function
developerr-ayush Oct 2, 2023
5733b78
Resolved comments and changes requests
developerr-ayush Oct 3, 2023
abac923
Merge branch 'master' of https://github.com/developerr-ayush/JavaScript
developerr-ayush Oct 8, 2023
8b8d0c6
Feat: Format duration code added
developerr-ayush Oct 8, 2023
cbf18cf
duration format
developerr-ayush Oct 9, 2023
79b6adf
Merge branch 'master' of https://github.com/developerr-ayush/JavaScript
developerr-ayush Oct 21, 2023
fe40752
Feat: Created matrix search function with test cases
developerr-ayush Oct 21, 2023
bf5f741
deleted-old-file
developerr-ayush Oct 21, 2023
1a15dd4
Update BinaryCountSetBits.js
developerr-ayush Oct 21, 2023
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Feat: TwoSum function created with test cases
  • Loading branch information
developerr-ayush committed Oct 2, 2023
commit bdf8ed8411bbe7fa418e2cfd50bc0250c628eaf8
18 changes: 18 additions & 0 deletions Maths/test/TwoSum.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { TwoSum } from '../TwoSum.js'

describe('Two Sum', () => {
it('Should find the indices of two numbers that add up to the target', () => {
expect(TwoSum([2, 7, 11, 15], 9)).toEqual([0, 1])
expect(TwoSum([15, 2, 11, 7], 13)).toEqual([1, 2])
expect(TwoSum([2, 7, 11, 15], 17)).toEqual([0, 3])
expect(TwoSum([7, 15, 11, 2], 18)).toEqual([0, 2])
expect(TwoSum([2, 7, 11, 15], 26)).toEqual([2, 3])
expect(TwoSum([2, 7, 11, 15], 8)).toEqual([])
expect(
TwoSum(
[...Array(10).keys()].map((i) => 3 * i),
19
)
).toEqual([])
})
})