Find all Duplicates in an Array (LeetCode 442) | Full solution with no Extra Space

Опубликовано: 21 Октябрь 2024
на канале: Nikhil Lohia
27,350
648

To see more videos like this, you can buy me a coffee: https://www.buymeacoffee.com/studyalg...

You are given an array of integers that have some values that appear twice and others appear once. Return a list of all the duplicate elements. Watch this video to learn 3 methods of solving this question. A Brute Force method, using a Hash-set with extra space and a trick to where you do not need any extra space. The biggest hint is that all the elements of the array are greater than equal to 1 and less than equal to the length of the array. Learn with great animations and visuals of what happens behind the scenes.

00:00 - Intro
01:19 - Problem Statement and description
03:24 - Method 1: Using HashSet
06:07 - Method 2: Without Extra Space
12:25 - Dry-run of Code
14:53 - Final Thoughts

📚 Links to topics I talk about in the video:
Brute Force Algorithm:    • Brute Force algorithms with real life...  
Time Complexity of an Algorithm:    • What is the Time Complexity of an Alg...  

Actual problem on LeetCode: https://leetcode.com/problems/find-al...

📘 A text based explanation is available at: https://studyalgorithms.com/array/lee...

Code on Github: https://github.com/nikoo28/java-solut...
Test-cases on Github: https://github.com/nikoo28/java-solut...

📖 Reference Books:
Starting Learn to Code: https://amzn.to/36pU0JO
Favorite book to learn algorithms: https://amzn.to/39w3YLS
Favorite book for data structures: https://amzn.to/3oAVBTk
Get started for interview preparation: https://amzn.to/39ysbkJ

🔗 To see more videos like this, you can show your support on: https://www.buymeacoffee.com/studyalg...

🎥 My Recording Gear:
Recording Light: https://amzn.to/3pAqh8O
Microphone: https://amzn.to/2MCX7qU
Recording Camera: https://amzn.to/3alg9Ky
Tablet to sketch and draw: https://amzn.to/3pM6Bi4


💻 Get Social 💻
Follow on Facebook at:   / studyalgos  
Follow on Twitter at:   / studyalgorithms  
Follow on Tumblr at:   / studyalgos  
Subscribe to RSS feeds: https://studyalgorithms.com/feed/
Join fan mail: http://eepurl.com/g9Dadv

#leetcode #programming #interview