STANAANDREY

sump

Jul 4th, 2021
980
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  function sumPairs(ints: number[], s: number): [number, number] | void {  
  2.   let setOfNr: Set<number> = new Set<number>();
  3.   ints.forEach((nr: number) => {
  4.     setOfNr.add(nr);
  5.   });
  6.   for (let nr of ints) {
  7.     let diff:number = s - nr;
  8.     if (setOfNr.has(diff)) {
  9.       return [nr, diff];
  10.     }
  11.   }
  12.   return undefined;
  13. }
  14.  
  15.  
RAW Paste Data