Created
July 13, 2017 16:55
-
-
Save betterkenly/623a781a462f25f608a51176ab8187e4 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 productExceptSelf(arr){ | |
var temp = []; | |
var product = 1; | |
for(var i = 0; i < arr.length; i++){ | |
temp[i] = product; | |
product *= arr[i]; | |
} | |
product = 1; | |
for(var i = arr.length - 1; i >= 0; i--){ | |
temp[i] *= product; | |
product *= arr[i]; | |
} | |
return temp; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment