Decode Strings (LeetCode 394) | Full solution with animations and examples | Study Algorithms
String encoding and decoding are widely used in encryption algorithms. This is often used to send encrypted messages. Hence, they make up good programming problems as well. In this particular problems you are given an encoded string, and we have to figure out the actual string. Watch the video to see a visual example of how the decoding works making it easier to follow and understand. All of this with a pseudo code.
Actual problem on LeetCode: leetcode.com/problems/decode-...
Chapters:
00:00 - Intro
00:45 - Problem statement and description
02:41 - Logic to decode the given string
05:35 - Finding an optimal solution to decode the string
10:57 - Pseudo code to decode strings
13:31 - Final Thoughts
📚 Links to topics I talk about in the video:
Brute Force Algorithmic Paradigms: • Brute Force algorithms...
What is Big O: • Big O Notation Simplif...
Stack Data Structure: • Stack Data Structure e...
Other problems on Strings: • Strings
📘 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
Пікірлер: 62
There is a comment issue in your pseudocode...The third condition says if there is "[". It should be "]"
@nikoo28
Жыл бұрын
Thanks for the correction. You are right.
Your explanations were clear and easy to follow, and the animations and examples you provided really helped solidify my understanding of the problem.
You seem like a friend with whom everyone wants to spend more time. Nice explanation btw.
@nikoo28
8 ай бұрын
this comment is full of warmth..thanks!! 😄
After watching the video I had to work on it myself and i finally figured the code. Thanx for the video
wow nikhil, you explained so well, far better than many of the paid courses, loved your teaching skills.
Hey Nikhil, Thank you Man, You explain things in very easy way, keep it up
What an amazing explanation sir, thank you so much ❤️
I smile, when i see that a Q. has been covered by you. Thank you sir.
@nikoo28
6 ай бұрын
🤗
I am a big fan of your teaching Skills
Your logic explaination is best , keep making such videos :)
@nikoo28
Жыл бұрын
trying my best everyday :)
You were phenomenal. Hats off sirrr!!!
@nikoo28
Жыл бұрын
thanks for your kind words
keep up the good work!!
Brilliant and Intuitve.
thank u so so much for the explanation
Your videos are awesome 🔥
great explanation :)
nice explanation!
you are my new fav instructor after sumeet malik, keep making more videos regularly! thanks alot.
@nikoo28
8 ай бұрын
so happy you feel this way
Very good explanation..
Thank you sir.Very handy approch and explanation.
@nikoo28
5 ай бұрын
You are welcome
this man is a goat
Thank you
nice!!!!!!!!!
thanks
thanks sir
you are osm thank you
best explanations
@nikoo28
Ай бұрын
Keep watching
do we need 2 stacks?
Very well explained I don't understand why their is less like to video
@nikoo28
9 ай бұрын
i dunno either 😂
Commendable explanation sir!! I just can say one line - Why fear when Nikhil Lohia is here.
@nikoo28
5 ай бұрын
🤘
Hi! Congrats for your solution! I am struggling to understand this bit of code k = (k * 10) + (c - '0') I print line by line with SYSO but I'm still no able to get it. When printing I get the following : when k = 1 (k * 10): 10 (c - '0'): 1 this is k: 1 Why k = (k * 10) + (c - '0') ends up with 1? As (k * 10) = 10 and (c - '0')= 1 why k is not 11? Could you please kindly clarify it?
@nikoo28
Жыл бұрын
The value of k = 0, not 1. :) Also when we push in the stack, once again we change it to 0.
how to handle multidigit number?
@nikoo28
7 ай бұрын
the solution handles a multi-digit number, check the github link in description :)
can you do it using 1 stack!
@iamnoob7593
Жыл бұрын
The solution here is more intutive. I would prefer using 2 stacks.
Abhi awaj bahut slow aaa rahi
Why we need to add another stack. Since get got first bracket that means if you say stack.peek() you will get the value. Its just waste of memory
@nikoo28
3 ай бұрын
The space complexity still remains the same O(n)
This solution doesn't work if the integer has more than one digit. e.g: 11[ab2[c]de].
@nikoo28
Жыл бұрын
It will work..for your test case the output will be abccdeabccdeabccdeabccdeabccdeabccdeabccdeabccdeabccdeabccdeabccde
@kolawoleabdulrahman
9 ай бұрын
it doesn't work for me as well.
100[leetcode] what will this give ;)0)
the code is very complex and is not easy to understand after watching this video tbh, might have made the soln just like the code
bhai isse accha toh mike mat he laga
@nikoo28
Жыл бұрын
Fixed those issues in my latest videos…thanks for the feedback :)
Explanation is too simple
Bro try to speak loudly
@nikoo28
9 ай бұрын
check my latest videos, if you still find the issue
bha sound quality bhtttttttttttttttttttttttttt hi gandiiii h ...mic cgange kro phle to aap