Amazon Coding Interview Question - Find All Duplicates in Array [LeetCode]

  Рет қаралды 19,221

AlgosWithMichael

AlgosWithMichael

Күн бұрын

Пікірлер: 48
@oooo-rc2yf
@oooo-rc2yf 3 жыл бұрын
Brilliantly simple implementation of permutation cycles, thanks for the walk through, due to that I was finally able to get it to click.
@noureddineettalhi9825
@noureddineettalhi9825 2 жыл бұрын
I saw only a video of your "slipping-window" so far, and I can already tell you are a great person. concision is good.
@hiradr3857
@hiradr3857 4 жыл бұрын
There is no way someone can come up with this solution in 30 minutes if they haven't seen it before lol
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
Lol agreed
@lylez00
@lylez00 Ай бұрын
I've been interviewing lately, and I'm not encountering any of these "common questions" I'm seeing on KZbin. They're all different, and they're all hard. My question today - just the question and the examples of solutions was 63 lines, and I had about 20 minutes to solve it. I am so sick of the IT industry!
@code7434
@code7434 4 жыл бұрын
Please cover more popular problems , that have these kind of tricky ways to reduce space complexity. Really liked the way u solved this problem
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
I will try my best! Thank you for watching :)
@heisenberg1844
@heisenberg1844 4 жыл бұрын
All your explanations are wonderful. Thank You.
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
You are welcome!
@lylez00
@lylez00 Ай бұрын
I wondered if the nums[index] = -nums[index] should be under an else statement, but when I tried that, in one of my test cases, it printed out one of the duplicate values twice.
@elmeroranchero
@elmeroranchero 10 ай бұрын
I guess the problem description is misleading, declaring an additional array/collection is extra space, specially arrayList and the kind, since those structures always have a buffer for adding elements.
@ManvendraSK
@ManvendraSK 4 жыл бұрын
Please keep doing this stuff. I also try this stuff but in JavaScript. Thanks.
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
I definitely will, thanks for watching!
@kasir-barati
@kasir-barati Ай бұрын
So basically we flip the numbers as a sign to see if we have already been there.
@mixupthings
@mixupthings 3 жыл бұрын
how do you get the Approach in first time??
@swargyahi904
@swargyahi904 2 ай бұрын
Simply use hashmap store key as num and value as count and incr val if already present in map and eventually return key which is greater than 2 val
@imranmohammed9814
@imranmohammed9814 2 ай бұрын
No extra space allowed.
@htphong24
@htphong24 2 жыл бұрын
Thanks a lot bro, you always have an excellent way of explaining solutions.
@jeffge8009
@jeffge8009 3 жыл бұрын
I wonder without knowing the solution in advance, how many people are able to come up with this solution during the 30min interview??
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
Likely not very many, myself included!
@kalyanamvenumadhav2245
@kalyanamvenumadhav2245 8 ай бұрын
Why we need to take negative based indexing can u ckarify this as you said that it's an zero based indexing and nunbers atarts from 1 to n then why we are taking negative indexing can't we get without that ?
@SusantaKumar-c4j
@SusantaKumar-c4j Ай бұрын
how to handle if any index value is more than the length of the array
@MrAbhinandan19
@MrAbhinandan19 5 ай бұрын
This solution will give ArrayIndexOutOfBounds exception, if any value in the array is greater than or equal to total array length plus 2. For example, if this array had a value, say 15, then as per solution, 15 - 1, means 14th index and there is no 14th index in the array.
@williamTjS
@williamTjS 3 ай бұрын
It can't because of the constraints
@rchukkapalli1
@rchukkapalli1 4 жыл бұрын
on line 12, we can just add => result.add(nums[i])?
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
We can't do that because nums[i] could be a negative number since on line 13 we swap signs.
@akashjoshi3298
@akashjoshi3298 3 жыл бұрын
Abs(nums[i]) can be added nd i think we should use set for storing the result instead of list because if any value present 4 times then this solution will add that particular value 2 times, which we don't need i think
@ParkourGenerationNew
@ParkourGenerationNew 6 ай бұрын
What a sleek solution, nice! Although I was thinking technically you are using extra space for the minus signs. If the constraints are that the array elements are positive, then you don't need an array of integers, you can do it with an array of unsigned integers, which would save you half your space. Then you can can use the other half for a bool array (or even a bit array which would be like 8-16 times more space effecient) and make it a more clear/readable solution using the same space. But yeah, that's probably more complicated to think of during an interview
@MBindu-kc2nj
@MBindu-kc2nj 2 жыл бұрын
Very helpful.Thank you so much 🤗
@sajalagarwal3486
@sajalagarwal3486 4 жыл бұрын
What if the elements doesn't lie in the range of the 1 to size of array? Then in that case what should be the most efficient approach?
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
In that case I would use a HashSet. You can add all of the numbers inside of the set and any numbers that fail to be added you know are dups!
@StateofMichigan-26thState
@StateofMichigan-26thState 3 жыл бұрын
Dude, You Rock!
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
Thanks Ethan! I appreciate you watching and commenting
@MBindu-kc2nj
@MBindu-kc2nj 2 жыл бұрын
Lots of love thank you
@maldannak6568
@maldannak6568 4 жыл бұрын
Thanks lot😊. Nice job your doing
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
Thank you!
@bhavyachawla7176
@bhavyachawla7176 4 жыл бұрын
amazing explanation !!!
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
Glad it was helpful!
@MBindu-kc2nj
@MBindu-kc2nj 2 жыл бұрын
I hope I will get offer because of you thank you in advance
@code7434
@code7434 4 жыл бұрын
Amazing
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
Thank you!
@tanweerchiktay
@tanweerchiktay Ай бұрын
Hi
@felixtube71
@felixtube71 6 ай бұрын
couldnt u sort with runtime of (n log n) then run thru array comparing i - 1 with i and then add dupe to result array?
@felixtube71
@felixtube71 6 ай бұрын
dont get me wrong, your's is cool, i was just curious.
@jorgegallego9672
@jorgegallego9672 2 ай бұрын
time complexity has to be O(n)
Amazon Coding Interview Question - First Missing Positive (LeetCode)
20:47
Amazon Coding Interview Question - Number of Distinct Islands
17:43
AlgosWithMichael
Рет қаралды 26 М.
Увеличили моцареллу для @Lorenzo.bagnati
00:48
Кушать Хочу
Рет қаралды 8 МЛН
FOREVER BUNNY
00:14
Natan por Aí
Рет қаралды 25 МЛН
ТВОИ РОДИТЕЛИ И ЧЕЛОВЕК ПАУК 😂#shorts
00:59
BATEK_OFFICIAL
Рет қаралды 6 МЛН
Microsoft Coding Interview Question - Rotate Image
17:21
AlgosWithMichael
Рет қаралды 9 М.
Easy Google Coding Interview With Ben Awad
28:00
Clément Mihailescu
Рет қаралды 1 МЛН
Find All Duplicates in an Array - Leetcode 442 - Python
9:40
NeetCodeIO
Рет қаралды 27 М.
Amazon Coding Interview Question - Clone Graph (LeetCode)
13:56
AlgosWithMichael
Рет қаралды 33 М.
Google Coding Interview Question - Plus One [LeetCode]
7:33
AlgosWithMichael
Рет қаралды 4,3 М.
Amazon Deep Learning Interview: Justify a Neural Network
11:25
Увеличили моцареллу для @Lorenzo.bagnati
00:48
Кушать Хочу
Рет қаралды 8 МЛН