Рет қаралды 14,214
Given an array of positive integers with some zeroes. You need to move all the zeroes to the end without changing the relative order of non-zero elements. At the first glance it feels that you will need to swap and move around a lot of elements to arrive at an efficient solution. This video explores a unique way of solving this problem and once you understand, it feels so easy and obvious. Watch the complete video with my final thoughts and a dry-run of code in JAVA.
Actual Problem on LeetCode: leetcode.com/problems/move-ze...
Chapters:
00:00 - Intro
01:12 - Problem statement and description
02:50 - Straight forward approach to move zeroes
04:15 - Space Efficient Solution In-place
06:56 - Dry-run of code
09:22 - Final Thoughts
📚 Links to topics I talk about in the video:
Brute Force Solution: • Brute Force algorithms...
What is Big O?: • Big O Notation Simplif...
Time Complexity: • What is the Time Compl...
More LeetCode problems: • Leetcode Solutions
📘 A text based explanation is available at: studyalgorithms.com
Code on Github: github.com/nikoo28/java-solut...
Test-cases on Github: github.com/nikoo28/java-solut...
📖 Reference Books:
Starting Learn to Code: amzn.to/36pU0JO
Favorite book to understand algorithms: amzn.to/39w3YLS
Favorite book for data structures: amzn.to/3oAVBTk
Get started for interview preparation: amzn.to/39ysbkJ
🔗 To see more videos like this, you can show your support on: www.buymeacoffee.com/studyalg...
🎥 My Recording Gear:
Recording Light: amzn.to/3pAqh8O
Microphone: amzn.to/2MCX7qU
Recording Camera: amzn.to/3alg9Ky
Tablet to sketch and draw: amzn.to/3pM6Bi4
Surface Pen: amzn.to/3pv6tTs
Laptop to edit videos: amzn.to/2LYpMqn
💻 Get Social 💻
Follow on Facebook at: / studyalgos
Follow on Twitter at: / studyalgorithms
Follow on Tumblr at: / studyalgos
Subscribe to RSS feeds: studyalgorithms.com/feed/
Join fan mail: eepurl.com/g9Dadv
#leetcode #programming #interview