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

preview_player
Показать описание
26 Remove Duplicates from Sorted Array LeetСode (Google Interview Question) JavaScript

"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:

Gear I use:
Рекомендации по теме
Комментарии
Автор

That one seems tough !!! Thanks for the explanation

alinasoltanici
Автор

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.

RogerThat
Автор

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

kasivishva
Автор

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);
};

momentswithmanisha
Автор

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

VindexTOS