Video není dostupné.
Omlouváme se.

Product of array except self (LeetCode 238) | Neetcode 7 / 150 | Bharath Chandra (Telugu)

Sdílet
Vložit
  • čas přidán 18. 08. 2024
  • Hello guys, cheers to another piece of learning. Today I talked about the "Product of array except self" problem which is the first in Neetcode 150 list. It is one of the most asked questions in interviews and has some interesting ways to solve it.
    In the above video, I showed all the different logics with which the problem can be solved and also the codes to those logics in Python. Let me know if you got a hold of the logic?
    Link to Prefix sum - • Prefix Sum Arrays| Pro...
    Link to the problem - leetcode.com/p...
    Link to Neetcode 150 - neetcode.io/pr...
    Regular updates from me on Discord, Insta and Telegram. I post job notifications of telegram and discord
    Insta - / bharathh_chandraa
    Telegram - t.me/thebharat...
    Discord - / discord
    LinkedIn - / lokesh-bharath-chandra...
    00:00 - Introduction and Problem Explanation
    02:12 - Straight forward approach
    05:47 - Brute Force
    11:43 - Optimisation
    18:59 - Pseudocode
    21:16 - Bonus question
    28:16 - Conclusion

Komentáře • 15

  • @niramalakanukolanu3222
    @niramalakanukolanu3222 Před měsícem +1

    Bro I Have Doubt How It Would Be suffix[0]= 1 it is 24 kadha

    • @bharathh_chandraa
      @bharathh_chandraa  Před měsícem

      Avunu Niramala, Thanks for pointing this out. It is 24, my mistake. Luckily, it did not change any answers

  • @electron-u8p
    @electron-u8p Před měsícem +2

    7/150 ✅️

  • @lohithaadapala6989
    @lohithaadapala6989 Před měsícem +3

    Ah! Found the perfect channel! Thankyou🙏

  • @tradeiteasyy
    @tradeiteasyy Před 22 dny

    Idea : iterate Evey element and get the left product and right product and multiply them and store the value in result array .

  • @Manipinnaka
    @Manipinnaka Před měsícem

    Baga chepav bro❤

  • @SaiBharath_Kanasani12
    @SaiBharath_Kanasani12 Před měsícem +2

    Hi bro, I have got the O(1) approach you told me in the last part of the video, but I am having a hard time coding that approach. can you tell me the code for that approach it would be helpful. Thank You!

    • @lohithaadapala6989
      @lohithaadapala6989 Před měsícem

      class Solution {
      public int[] productExceptSelf(int[] nums) {
      int n = nums.length;
      int[] output = new int[n];

      output[n-1] = nums[n-1];
      for(int i=n-2;i>=0;i--){
      output[i] = output[i+1] * nums[i];
      }
      for(int i=1;i

  • @vaneetha_here_navaneetha
    @vaneetha_here_navaneetha Před měsícem

    class Solution:
    def productExceptSelf(self, nums):
    n=len(nums)
    suffix=[1]*n
    suffix[n-1]=nums[n-1]
    for i in range(n-2,-1,-1):
    suffix[i]=suffix[i+1]*nums[i]
    for i in range(1,n):
    nums[i] = nums[i-1] *nums[i]
    for i in range(n):
    if i==0:
    suffix[i]=suffix[i+1]
    elif i==(n-1):
    suffix[i]=nums[-2]
    else:
    suffix[i]=(suffix[i+1] * nums[i-1])
    return suffix

  • @user-ir5mm9pt8v
    @user-ir5mm9pt8v Před měsícem +1

    Waiting anna

  • @vaneetha_here_navaneetha
    @vaneetha_here_navaneetha Před měsícem

    class Solution:
    def productExceptSelf(self, nums):
    n=len(nums)
    prefix=[1]*n
    prefix[0]=nums[0]
    for i in range(1,len(nums)):
    prefix[i]=prefix[i-1]*nums[i]
    suffix=[1]*n
    suffix[n-1]=nums[n-1]
    for i in range(n-2,-1,-1):
    suffix[i]=suffix[i+1]*nums[i]
    l=[]
    for i in range(len(nums)):
    if i==0:
    l.append(suffix[i+1])
    elif i==(n-1):
    l.append(prefix[n-2])
    else:
    l.append(suffix[i+1] * prefix[i-1])
    return l
    after watching video

  • @vaneetha_here_navaneetha
    @vaneetha_here_navaneetha Před měsícem

    class Solution:
    def productExceptSelf(self, nums: List[int]) -> List[int]:
    c=nums
    l=[]
    for j in range(len(nums)):
    n = c[:j]+c[j+1:]
    p=1
    for i in n:
    p=p*i
    l.append(p)

    return l
    before starting the video

  • @KumarTatikonda
    @KumarTatikonda Před měsícem +1

    Thumbnail loo leet code symbol pettu Anna Inka perugutgadi reach

  • @VincentVamsi
    @VincentVamsi Před měsícem