Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function sumPairs(ints: number[], s: number): [number, number] | void {
- let setOfNr: Set<number> = new Set<number>();
- ints.forEach((nr: number) => {
- setOfNr.add(nr);
- });
- for (let nr of ints) {
- let diff:number = s - nr;
- if (setOfNr.has(diff)) {
- return [nr, diff];
- }
- }
- return undefined;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement