Skip to content

Instantly share code, notes, and snippets.

@NhanKhangg98
Last active October 16, 2022 08:54
Show Gist options
  • Save NhanKhangg98/c0318ae2fe983b94b62b59989dd23872 to your computer and use it in GitHub Desktop.
Save NhanKhangg98/c0318ae2fe983b94b62b59989dd23872 to your computer and use it in GitHub Desktop.
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