Subsets 2 (LeetCode 90) | Full solution with backtracking examples | Interview | Study Algorithms
Vložit
- čas přidán 29. 07. 2024
- An extension to the original problem on subsets. The requirement is exactly the same of finding the power set, but this time there is an added complexity of having duplicates in the array. Nothing to get worried about, in this video we see how to tackle those duplicates and what problems do they cause when we approach this problem in the same way. You will get to know how the state space tree looks like and what can you do to make sure that the duplicates are addressed gracefully. All along with beautiful examples, animations and a dry-run of code in JAVA.
Actual problem on LeetCode: leetcode.com/problems/subsets...
Chapters:
00:00 - Intro
01:16 - Problem statement and description
03:09 - Deviation and similarity from Subsets 1
06:57 - Dry-run of Code
10:35 - Final Thoughts
📚 Links to topics I talk about in the video:
Subsets I: • Subsets (LeetCode 78) ...
Backtracking Algorithmic Paradigm: • Backtracking made easy...
Recursion: • Recursion paradigms wi...
Other problems on LeetCode: • 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 #backtracking #interview
thanks alot bhaiya I always look for ur videos even when I solve the problem my self as everytime I learn something from ur videos.
my respect towards your explanation sir
U ARE THE BEST EXPLAINER OF THE LEETCODE. Just keep it up bro🔥
trying my best
After watching Subsets and permutations, I was able to solve it on my own! Thanks
Excellent!
Hey @nikoo28, I am a regular viewer of your videos and honestly they are very helpful in understanding the concepts clearly. I have just a small suggestion for this explanation. Although, this approach works, but it is not optimal. Also, for someone like me who uses javascript, the includes method in js (equivalent to contains in java) will return false. Another approach can be to check inside the loop
if(i > start && nums[i - 1] === nums[i]) continue;
Not running the loop when this condition is there and this shall also give the same result.
Nonetheless, please keep making these videos. You have no idea how much it makes our lives easier. Thank you for all the effort you put in. Cheers!
Thank you
Brother, give me an order. Which playlist of your channel should I watch first and then what? Can you make some math videos? I am not very good at math but not that weak as well. Will you make it easy by teaching what exactly we need?
The best way to start would be starting the Algorithmic Paradigms list
Then move on to Data Structures.
Start solving and look problems on LeetCode easy problems
That will give you some direction on getting started.
Reach out to me if you have more doubts.
If you are putting result lists in set and checking if it contains the list than why you have sorted first no need to sort!!!
we want to remove all duplicates, hence sorting helps
There is no need to use set.
If you have already sorted the nums array simply add condition in for loop i.e
if(i>idx && nums[i]==nums[i-1])
continue;
duplicates will be already removed
Where is he using the set?
@@pratikdey4239 to check for the duplicates
very bad explaination
which part did you struggle with?
@@nikoo28it was way better than others it helped me a lot
.....just a question is it a full solution for back track approach and language u used it is Java??