├── .DS_Store ├── README.md └── app.ts /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devDoubleH/qwasar_print_duplicates/HEAD/.DS_Store -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Qwasar silicon valley 2 | 3 | This is a project for the Qwasar Silicon Valley program. 4 | 5 | # Description 6 | Given two sorted arrays passed as parameters, 7 | create a function able to return all the number that are present 8 | in one array and in the other. 9 | -------------------------------------------------------------------------------- /app.ts: -------------------------------------------------------------------------------- 1 | const print_duplicates = ( 2 | arr1: number[], 3 | num1: number, 4 | arr2: number[], 5 | num2: number 6 | ): number[] => { 7 | let i = 0; 8 | let j = 0; 9 | let duplicates: number[] = []; 10 | 11 | while (i < num1 && j < num2) { 12 | if (arr1[i] < arr2[j]) { 13 | i++; 14 | } else if (arr2[j] < arr1[i]) { 15 | j++; 16 | } else { 17 | duplicates.push(arr2[j]); 18 | i++; 19 | j++; 20 | } 21 | } 22 | 23 | return duplicates; 24 | }; 25 | --------------------------------------------------------------------------------