Last active
October 16, 2022 08:54
-
-
Save NhanKhangg98/c0318ae2fe983b94b62b59989dd23872 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function findProduct(...arr:number[]): number[]{ | |
| let rt: number[] = []; | |
| let temp = 1; | |
| for (let i = 0; i < arr.length; i++) { | |
| rt[i] = temp | |
| temp *= arr[i] | |
| } | |
| temp = 1 | |
| for (let j = arr.length-1; j >= 0; j--) { | |
| rt[j] *= temp | |
| temp *= arr[j] | |
| } | |
| return rt; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment