DEV Community

Lautaro Suarez
Lautaro Suarez

Posted on

1

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.

Image of AssemblyAI

Automatic Speech Recognition with AssemblyAI

Experience near-human accuracy, low-latency performance, and advanced Speech AI capabilities with AssemblyAI's Speech-to-Text API. Sign up today and get $50 in API credit. No credit card required.

Try the API

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 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