26 Remove Duplicates from Sorted Array LeetСode (Google Interview Question) JavaScript

Поделиться
HTML-код
  • Опубликовано: 1 фев 2025
  • 26 Remove Duplicates from Sorted Array LeetСode (Google Interview Question) JavaScript
    leetcode.com/p...
    "Given an integer array nums sorted in non-decreasing order, remove the duplicates in-place such that each unique element appears only once. The relative order of the elements should be kept the same."
    Final Code:
    replit.com/@de...
    Gear I use:
    1) Blue Yeti microphone - amzn.to/3ys9Te2
    2) Logitech HD Pro Webcam C920 - amzn.to/3kuntZw
    3) Monitor - amzn.to/3ynjJhe
    4) Ipad - amzn.to/3BjoQAZ

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

  • @sergiyrudenko905
    @sergiyrudenko905 2 года назад +1

    Great! Thanks Alex!

  • @Yakuza13329
    @Yakuza13329 Год назад +11

    How TF is this considered easy?

  • @kasivishva3183
    @kasivishva3183 9 месяцев назад +2

    Function removeduplicates(arr){
    return Array.from(new set(arr))
    }
    Const numbers = [1,2,3,3,3,4,4,6,6,7]
    Const uniquenunbers= removeduplicates(numbers)
    Console.log(uniquenumbers)
    Can you explain why this is not accepted

  • @alinasoltanici5751
    @alinasoltanici5751 3 года назад

    That one seems tough !!! Thanks for the explanation

  • @RogerThat902
    @RogerThat902 3 года назад

    Nice explanation. This one is "hard" only because you kind of have to know exactly what they are looking for IMO. An interviewer would be able to fill in the details but left w/ just the question I can see how people assume a much easier way to come up w/ the answer that has the same time and space complexity. I'm not a fan of the question for that reason. Great video though and subscribed.

  • @Momentswithmanisha
    @Momentswithmanisha Год назад +2

    can you pls explain why the solution below is not accepted , in local I am getting desired result but not at the leet code platform.
    var removeDuplicates = function(nums) {
    const uniqueElement = new Set(nums);
    return Array.from(uniqueElement);
    };

    • @SweepAndZone
      @SweepAndZone 9 месяцев назад

      when you're initializing the Set, is that sticking to the rule of doing the operation in place? or are you creating a new array?

    • @pbjcomedy
      @pbjcomedy 4 месяца назад +1

      I think you are not supposed to allocate space for a new array or set.

  • @SamDavis-b4u
    @SamDavis-b4u Год назад

    Thanks

  • @dtorcates
    @dtorcates 2 года назад

    Really good, thank you

  • @glow273
    @glow273 Год назад

    thanks

  • @VindexTOS
    @VindexTOS Год назад +1

    console out put was asking me to output an array while in reality it was asking me to put out index of the cut out