Remove Duplicates From Sorted Array - Leetcode 26 - Arrays & Strings (Python)

Поделиться
HTML-код
  • Опубликовано: 12 ноя 2024

Комментарии • 17

  • @GregHogg
    @GregHogg  2 месяца назад

    Master Data Structures & Algorithms for FREE at AlgoMap.io/

  • @asvlog425
    @asvlog425 2 месяца назад

    I saw so many videos but your explanation was great for me to understand the concept. Thank you

  • @pravinprince3221
    @pravinprince3221 3 месяца назад

    thank you for the wonderful video Greg, very useful thanks again

  • @benhurthandu6821
    @benhurthandu6821 5 дней назад

    why the error 'return' outside function?

  • @NoTMaFiA24
    @NoTMaFiA24 3 месяца назад

    can you please also make videos on daily challenges of leetcode
    love your videos, you teach us in nice way👍👍

  • @LawZist
    @LawZist 3 месяца назад

    The drawing is so helpful! Can you do calculator leet code question?

  • @yygysgtyfugunvt
    @yygysgtyfugunvt 3 месяца назад

    Hi Greg could you please provide the provide the discord server link?

  • @chandershekhar9251
    @chandershekhar9251 3 месяца назад

    Please make videos on leetcode POTD sir

  • @BossganabathiVellow
    @BossganabathiVellow 3 месяца назад

    class Solution(object):
    def removeDuplicates(self, nums):
    """
    :type nums: List[int]
    :rtype: int
    """
    a = []
    for num in nums:
    if num not in a:
    a.append(num)
    return len(a)
    nums = [1,1,2]
    solve = Solution()
    print(solve.removeDuplicates(nums))
    this is my method when running in online complier no error showing but when runs in leetcode showing error. Sir can explain me why this can happend ?

    • @MaksymOliinyk-z5u
      @MaksymOliinyk-z5u 2 месяца назад +1

      hi, you need to modify exactly the nums array that you have in your function, you should not create any new arrays

  • @BossganabathiVellow
    @BossganabathiVellow 3 месяца назад

    class Solution(object):
    def removeDuplicates(self, nums):
    """
    :type nums: List[int]
    :rtype: int
    """
    a = []
    for num in nums:
    if num not in a:
    a.append(num)
    return len(a)
    nums = [1,1,2]
    solve = Solution()
    print(solve.removeDuplicates(nums))
    this is my method showing error but online complier didn't show any error the reason why ?

    • @amlet00
      @amlet00 2 месяца назад +1

      because you need do it in-place, that means you cannot use any extra space

    • @BossganabathiVellow
      @BossganabathiVellow 2 месяца назад

      @@amlet00 Thank you sir

  • @tejas8211
    @tejas8211 2 месяца назад

    This ain't easy mannnnn

  • @MohamedAbdallahdjedouani
    @MohamedAbdallahdjedouani 3 месяца назад

    return len(set(nums))
    i think this gonna work , no ?

    • @GregHogg
      @GregHogg  3 месяца назад +3

      Yeah you should read the question again haha

    • @SwizzRizzBizz
      @SwizzRizzBizz Месяц назад

      Wont work because sets are unordered and the question asks to keep the order of the given array! So you cannot use a set data structure