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
Great! Thanks Alex!
How TF is this considered easy?
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
That one seems tough !!! Thanks for the explanation
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.
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);
};
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?
I think you are not supposed to allocate space for a new array or set.
Thanks
Really good, thank you
thanks
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