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

Поділитися
Вставка
  • Опубліковано 19 гру 2024

КОМЕНТАРІ •

  • @GregHogg
    @GregHogg  3 місяці тому

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

  • @santhoshd7938
    @santhoshd7938 24 дні тому +4

    When I can't understand something on Neetcode, I come here. Now, Greg Hogg is my first priority.

  • @asvlog425
    @asvlog425 3 місяці тому +1

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

  • @pravinprince3221
    @pravinprince3221 4 місяці тому

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

  • @NoTMaFiA24
    @NoTMaFiA24 4 місяці тому

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

  • @josephajoseph9535
    @josephajoseph9535 14 днів тому

    If the array size is 1 it would throw an index error right

  • @LawZist
    @LawZist 4 місяці тому

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

  • @benhurthandu6821
    @benhurthandu6821 Місяць тому

    why the error 'return' outside function?

  • @chandershekhar9251
    @chandershekhar9251 4 місяці тому

    Please make videos on leetcode POTD sir

  • @yygysgtyfugunvt
    @yygysgtyfugunvt 4 місяці тому

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

  • @BossganabathiVellow
    @BossganabathiVellow 4 місяці тому

    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 4 місяці тому +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 4 місяці тому

    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 4 місяці тому +1

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

    • @BossganabathiVellow
      @BossganabathiVellow 4 місяці тому

      @@amlet00 Thank you sir

  • @tejas8211
    @tejas8211 3 місяці тому

    This ain't easy mannnnn

  • @MohamedAbdallahdjedouani
    @MohamedAbdallahdjedouani 4 місяці тому

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

    • @GregHogg
      @GregHogg  4 місяці тому +3

      Yeah you should read the question again haha

    • @SwizzRizzBizz
      @SwizzRizzBizz 3 місяці тому

      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

  • @eduardmaievskyi6947
    @eduardmaievskyi6947 19 днів тому

    This is one of the worst problem descriptions they have on LettCode. How could someone formulate such a simple task in such a complicated and unclear way? :)