Back to Browse

Arrays Series #8- Product of Array except itself - (Medium) - Solution Explained in Java

208 views
Aug 15, 2022
15:10

Given an array nums[] of size n, construct a Product Array P (of same size n) such that P[i] is equal to the product of all the elements of nums except nums[i]. Example 1: Input: n = 5 nums[] = {10, 3, 5, 6, 2} Output: 180 600 360 300 900 Explanation: For i=0, P[i] = 3*5*6*2 = 180. For i=1, P[i] = 10*5*6*2 = 600. For i=2, P[i] = 10*3*6*2 = 360. For i=3, P[i] = 10*3*5*2 = 300. For i=4, P[i] = 10*3*5*6 = 900. Example 2: Input: n = 2 nums[] = {12,0} Output: 0 12 Expected Time Complexity: O(n) Expected Auxiliary Space: O(n) ➡️Practice links: https://leetcode.com/problems/product-of-array-except-self/ --------------------------------------------------------- Please click the LIKE button so that this kind of content can be seen by as many as possible aspiring engineers and professionals. Doing so gives me even more motivation to post such content in the future. Please comment below and let me know if you have any questions or concerns. Additionally, don't forget to click the bell symbol to receive notifications and subscribe to the channel. Follow us on: ➡️Twitter - https://twitter.com/CodeEase ---------------------------------------------------------- Created and Instructed by: Varsha Das Mid-senior Software Engineer, Content Curator of @Code With Ease ➡️ LinkedIn - https://www.linkedin.com/in/varsha-das-se/ ➡️ Quora - https://www.quora.com/profile/Varsha-Das-11 ➡️ Hashnode - https://varsha-das.hashnode.dev/ Code With Ease is meant to make problem-solving in programming easier. For DSA preparation, we post topic-specific videos pertaining to Coding Interview topics so that everyone may approach such questions with a clear thought process and achieve the best outcomes. In addition, we make an effort to include different "Primer Series" that teach particular concepts or algorithms. We want to be the one-stop solution for everything pertaining to DSA preparation and programming foundations in general, saving candidates from having to visit many sources in order to receive structured content. Additionally, we believe that learning to code entails much more than only "cracking the coding interview." The long-term goal of this channel is to create more proficient problem-solvers in this field so that, in the end, we can create fantastic products and be able to resolve challenging issues in our environment to improve the quality of life for everyone. #codinginterviewquestions #dsa #codewithease #datastructureandalgorithm #programming #javaprogramming #arraysinjava #productofarrrayexceptitself

Download

1 formats

Video Formats

360pmp419.3 MB

Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.

Arrays Series #8- Product of Array except itself - (Medium) - Solution Explained in Java | NatokHD