Third day posting about Blind 75 LeetCode Questions.
Today i will be solving the Product of Array Except Self.
Let`s set up the problem first.
We are being asked to return an array "answer" such that "answer[i]" is equal to the product of all the elements of "nums" except "nums[i]".
We will start by defining "resultArray" and "product"
Then we will make a first for loop and inside it we will re declared "product".
Inside of it for loop we will make a second loop and an if statement inside it that will check if "i" is not equal to "j" and if it is not it will re declared product multipliying it by "nums[j]".
And finally just inside the first loop we will push "product" into the first empty array declared.
Final code:
Thanks, i will be uploading every day.
Hope someone found it useful.
Lautaro.
Top comments (0)