I came across this video while doing leetcode problems looking for help. Your explanation here is really great and much appreciated. I'm subscribed now and really looking forward to checking out your other vids!
@LucidProgramming3 жыл бұрын
Cheers! If you enjoyed and benefited from my content, please consider liking the video and subscribing to the channel for more content like this. If you would like to support the content creation on this channel please consider unblocking ads when watching my videos as this is how I support my time to make content. I hope to be putting out more similar videos soon!
@mahmoudtokura4 жыл бұрын
This playlist has been absolutely brilliant, your explanations are so easy to follow and remember. Thank you so much. I hope you do a playlist on leetcode or codewars questions, that would be awesome. Thanks again
@LucidProgramming4 жыл бұрын
Cheers! If you enjoyed and benefited from my content, please consider liking the video and subscribing to the channel for more content like this. If you would like to support the content creation on this channel please consider unblocking ads when watching my videos as this is how I support my time to make content. I hope to be putting out more similar videos soon!
@debupatra23334 жыл бұрын
Thank you for this playlist , really this is clearly the best for python Algo. Your teaching methods are very productive and easy to catch up.
@LucidProgramming4 жыл бұрын
Cheers! If you enjoyed and benefited from my content, please consider liking the video and subscribing to the channel for more content like this. I hope to be putting out more similar videos soon!
@rjedwards1586 жыл бұрын
Your walk thru of typical python interview questions are very good. Much better than a lot of other users (such as CS Dojo). I think if you were to title your videos "Interview Questions in Python" or something similar rather than "Algorithms in python" like a lot of the other users you may get much higher views (if this is your aim). I think your content is very good but maybe you should bigup your site a bit.
@vinoddiwan57924 жыл бұрын
agree with you CS Dojo is just a big mouth Ex Google Employee
@KippiExplainsStuff5 жыл бұрын
This was a fun little exercise :) my approach was slightly different and I would love for you to look at it and see if there is any disadvantage compared to your method (other than having more lines of code): def generate_next_number(num): new_num = "" count = 1 for i in range(len(num) - 1): if num[i] == num[i+1]: count += 1 else: new_num += str(count) + num[i] count = 1 # This takes care of the last digit if count == 1: new_num += "1" + num[-1] else: new_num += str(count) + num[-1] return new_num
@LucidProgramming5 жыл бұрын
Cool! From what I can tell, it looks like your approach works. It is kind of a fun problem, and I'm glad you had a good time with it. Cheers, and thanks as always for watching, Amos!
@sarbjitgahra46676 жыл бұрын
That was done so well. Thank you for your knowledge.
@LucidProgramming6 жыл бұрын
Thank you very much Sarbjit, I'm thrilled to hear that. :). You're very welcome, and I look forward to continuing to share it. Cheers, and thanks again for watching!
@Mahdi_B5 жыл бұрын
Thanks, this was a big help!
@LucidProgramming5 жыл бұрын
Thank you! If you like my content, I've been working on some projects during the past couple of months. If you would like to stay up-to-date, please consider subscribing to my mail list. Also, if you haven't already, please consider subscribing! I really appreciate the support, and if you want to support the channel, I do have a PayPal link www.paypal.me/VincentRusso1 for donations that go directly to the creation of content on this channel. I hope that the content I provide there will enhance the videos on my KZbin page. bit.ly/lp_email
@chiragsoni29465 жыл бұрын
Great Explanation. I wonder what is the time complexity of this solution. Is it O(n2), n being the length of the largest string?
@LucidProgramming5 жыл бұрын
Thanks, Chirag. One thing I would be mindful of when calculating the runtime is that there is also an outer loop that goes over "n" times and the length of the string (call that "m") as something else. I think your calculation needs a bit of a refinement to fully capture this solution.
@simonfraile37254 жыл бұрын
I have to say, this was really cool and helpful. But I have to ask, do you have a job related to programing or is it just like a hobby??
@LucidProgramming4 жыл бұрын
Thanks. And both!
@simonfraile37254 жыл бұрын
@@LucidProgramming What is your job??
@LucidProgramming4 жыл бұрын
@@simonfraile3725 You can find out all that info on my website listed in the "about" section of my channel. Cheers!
@simonfraile37254 жыл бұрын
LucidProgramming ok thank you really much
@LucidProgramming4 жыл бұрын
@@simonfraile3725 Sure, no problem.
@janhavibhosle6834 жыл бұрын
Thank you so much!!
@LucidProgramming4 жыл бұрын
Cheers! If you enjoyed and benefited from my content, please consider liking the video and subscribing to the channel for more content like this. If you would like to support the content creation on this channel please consider unblocking ads when watching my videos as this is how I support my time to make content. I hope to be putting out more similar videos soon!
@niazahmad78234 жыл бұрын
basically i did the same question but with better complexity, you can check it out. it is using one loop internally instead of 2 loops and it also uses recursion for n. if any one need help ask i will help. def substr(n, s): if n==0: return(s) l = [] count = 0 cur = None length=len(s) for i in range(length): if s[i] == cur: count += 1 else: if cur is not None: l.append((cur, count)) cur = s[i] count = 1 l.append((cur, count)) an=[] for i in l: an.append(i[1]) an.append(int(i[0])) return substr(n-1,an) s=[1] ans=substr(4,s) print(ans)
@LucidProgramming4 жыл бұрын
I don't see how this is a better complexity. In fact, this seems to be worse than what is shown in the video.
@niazahmad78234 жыл бұрын
@@LucidProgramming you are using two loops internally to calculate the next number then you are using one loop for n so you are basically doing it in O(n3). I am using one loop to calculate the next number and using recursion for n. And time wise recursion is O(n). So my code is doing it in O(n2) i may be wrong but thats what my understanding is
@niazahmad78234 жыл бұрын
@@LucidProgramming now I did it using a loop instead of recursion and the complexity of the whole program is O(n2) and one that is shown in the video has the complexity of O(n3) def substr(s): l = [] count = 0 cur = None length=len(s) # 1st pass for i in range(length): if s[i] == cur: count += 1 else: if cur is not None: l.append((cur, count)) cur = s[i] count = 1 l.append((cur, count)) an=[] for i in l: an.append(i[1]) an.append(int(i[0])) return an s=[1] n=4 for i in range(4): s=substr(s) print(s)
@LucidProgramming4 жыл бұрын
@@niazahmad7823 How is two loops O(n^3)? Two loops would be O(n^2).
@niazahmad78234 жыл бұрын
@@LucidProgramming sir you are using two loop in function and one loop in the main that makes it O(n3)
@yt-11612 жыл бұрын
this was interesting
@LucidProgramming2 жыл бұрын
Cheers! If you enjoyed and benefited from my content, please consider liking the video and subscribing to the channel for more content like this. If you would like to support the content creation on this channel please consider unblocking ads when watching my videos as this is how I support my time to make content. I hope to be putting out more similar videos soon!
@moeal51104 жыл бұрын
How can we do this recursively?
@LucidProgramming4 жыл бұрын
Check my recursion playlist.
@shubhamh74513 жыл бұрын
by any chance, can we use count function in this problem? something like, print(list.count[i] , i) and maybe for other number as well and then append all together? did anyone also happen to think this way or is it wrong?
@LucidProgramming3 жыл бұрын
You could, although this runtime would be worse. You'd have two loops--one for iterators "i" and "j" and then another factor of "n" for the count function, which would increase the runtime to O(n^3) instead of O(n^2).
@shubhamh74513 жыл бұрын
@@LucidProgramming got it!
@titouanriot36635 жыл бұрын
why do you write Len(s) ? it is an 'int' so I do not understand
@LucidProgramming5 жыл бұрын
No, it isn't an int. It's in between quotes and therefore treated as a string.
@jishanshaikh20033 жыл бұрын
What is meant by running time of an algorithm? What are the different types of running time? Like I heard n, log(n), etc. What is meant by this, and how are they identified? Can anyone please explain??
@LucidProgramming3 жыл бұрын
It's a general metric to measure the number of computational steps to complete an algorithm. I'm not going to be able to go into detail here, but I suggest looking into "Big Oh" notation on Wikipedia.