DEV Community

Lautaro Suarez
Lautaro Suarez

Posted on

Product of Array Except Self

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"

Image description

Then we will make a first for loop and inside it we will re declared "product".

Image description

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]".

Image description

And finally just inside the first loop we will push "product" into the first empty array declared.
Final code:

Image description

Thanks, i will be uploading every day.
Hope someone found it useful.

Lautaro.

Billboard image

Monitoring as code

With Checkly, you can use Playwright tests and Javascript to monitor end-to-end scenarios in your NextJS, Astro, Remix, or other application.

Get started now!

Top comments (0)

nextjs tutorial video

Youtube Tutorial Series

So you built a Next.js app, but you need a clear view of the entire operation flow to be able to identify performance bottlenecks before you launch. But how do you get started? Get the essentials on tracing for Next.js from @nikolovlazar in this video series 👀

Watch the Youtube series

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay