HackerRank - Super Reduced Strings | Full solution with visuals and examples | Study Algorithms
14:31
Backspace String Compare (LeetCode 844) | Full solution with actual examples | Study Algorithms
13:24
HackerRank - Two Characters | Full solution and examples | Study Algorithms
Вставка
- Опубліковано 16 гру 2024
Perfect Solution and great content man ! It'd be helpful if you explain intuitions behind such not so mainstream approaches. Overall this was more than I could ask for. Thanks.
Thank you so much for your support. At around 8:12 in the video, I describe my approach for the problem. Please do watch my video on dynamic programming to get a general idea on how to go about solving these problems.
ua-cam.com/video/fqvwVE0Ds94/v-deo.html
Once again, thanks for your support. Please share the video with people you know it may be helpful :)
@Study Algorithms The time complexity of brute force solution mentioned here is not O(n^3)
No. of possible combinations in the worst case are 26c2 --> A linear scan to check each combination gives you O(26*25/2 * n) which is O(n)
In the dp solution again, we are constructing the DP matrix with 26*26 elements in the worst case scenario, and linear scan gives O(n) for each remaining combination which is left out after parsing the string. To get the complexity of DP soln, you have used same logic that remaining cases are at best 26C2 ( constant in the worst case), and linear scan is O(n).
i dont't know how to implement dynamic programing (Algorithams) in a code ... can you make separate videos for that ... it will be really helpful !
Hi, I have uploaded 2 videos to simplify dynamic programming for you
Part 1: ua-cam.com/video/tHqTq-H5utI/v-deo.html
Part 2: ua-cam.com/video/fqvwVE0Ds94/v-deo.html
Please share them with your friends as well, if you find them helpful.
@@nikoo28 yaa ofcourse... i will share ..ur material are really helpful
i can't see the connection between the problem and the table
Most underrated channel🙏
For this problem brute force works fine and all test cases pass without TLE. But I will try to implement it using DP. Thanks :)
Yep, a brute force would work but that is just because the problem is categorised as Easy in HackerRank. With tighter time limits you would need DP.
Goodluck :)
@@nikoo28 OK, I got it.
Nice explanation
Awesome explanation :)
Thank you sir
Time complexity for the given solution is O(n^2) but not O(n), please correct me if I'm wrong?
If you look at the loops closely, only the outer loop runs till the length(n) of string. The inner loop runs only of NUM_LETTERS = 26 times.
This will always happen in a constant time, and hence it will not increase exponentially if the length of the string increases.
why not 2d char array is taken?? On taking all test cases does not get passed.
what do you mean by taking a 2d char array. In the solution, I use an integer array where each integer maps to a character. All the test cases pass. Look at the solution in the video description. :)
when I took 2d char array my all test cases does not get passed...why??
can't actually help with debugging your code. Try to put in some print statements and run some edge cases. That can help to identify the logical error you are having.
you should add the code along with the theoretical explanation
Check the video description. You will find a link to the code
i guess dp solution is not constant space coz we are constructing a table
appreciated
DP? And this is marked as easy in HankerRank, lol🤣
bro could we solve it by regex please solve it by regex and give a vidieo tutorial with regex
why do you want to solve it with regex?