LeetCode 442: Find Array Duplicates SOLVED | Facebook Coding Interview Question

preview_player
Показать описание
According to Leetcode, this question has been asked by Facebook 126 times. I even met someone on Pramp who interviewed at Facebook recently and they also got the exact same question. So if you're looking to land that dream job at Facebook, you should definitely know how to solve this question. In this video I'll walk you through the iterative solution. Happy Coding!

TIME STAMPS
--------------------------------------------------------------------------------------------------------
Conceptualization: 0:45
Code: 1:30
Complexity Analysis: 5:00

QUESTION LINKS
---------------------------------------------------------------------------------------------------------
Difficulty: Medium

MY LINKS
--------------------------------------------------------------------------------------------------------
Рекомендации по теме
Комментарии
Автор

Nice. Bro ! Everything you just said in this vid who taught it too you?? The computer science classes or no??

lillyinthefield
Автор

This question you can use the index as the marker by multiply -1 to the element as the corresponding index, since the value of elements are in the range 1 to n. For instance, if you see element with absolute value ( we use absolute since we manipulate the elements for marking the visited numbers) = 2, you may try to multiply -1 to the element at index 1 (since 1=2-1). If the value of the element of that index 1 is already negative, meaning that there is another element with value = 2 has been counted one time before => add this to the answer array

hoangnguyendinh
Автор

How to make sure all the duplicates are unique without extra space?

NagaVenkateshgavini