String Processing in Python: Look-and-Say Sequence

  Рет қаралды 19,337

LucidProgramming

LucidProgramming

Күн бұрын

Пікірлер: 44
@caseykongpanickul3426
@caseykongpanickul3426 3 жыл бұрын
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!
@LucidProgramming
@LucidProgramming 3 жыл бұрын
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!
@mahmoudtokura
@mahmoudtokura 4 жыл бұрын
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
@LucidProgramming
@LucidProgramming 4 жыл бұрын
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!
@debupatra2333
@debupatra2333 4 жыл бұрын
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.
@LucidProgramming
@LucidProgramming 4 жыл бұрын
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!
@rjedwards158
@rjedwards158 6 жыл бұрын
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.
@vinoddiwan5792
@vinoddiwan5792 4 жыл бұрын
agree with you CS Dojo is just a big mouth Ex Google Employee
@KippiExplainsStuff
@KippiExplainsStuff 5 жыл бұрын
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
@LucidProgramming
@LucidProgramming 5 жыл бұрын
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!
@sarbjitgahra4667
@sarbjitgahra4667 6 жыл бұрын
That was done so well. Thank you for your knowledge.
@LucidProgramming
@LucidProgramming 6 жыл бұрын
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_B
@Mahdi_B 5 жыл бұрын
Thanks, this was a big help!
@LucidProgramming
@LucidProgramming 5 жыл бұрын
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
@chiragsoni2946
@chiragsoni2946 5 жыл бұрын
Great Explanation. I wonder what is the time complexity of this solution. Is it O(n2), n being the length of the largest string?
@LucidProgramming
@LucidProgramming 5 жыл бұрын
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.
@simonfraile3725
@simonfraile3725 4 жыл бұрын
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??
@LucidProgramming
@LucidProgramming 4 жыл бұрын
Thanks. And both!
@simonfraile3725
@simonfraile3725 4 жыл бұрын
@@LucidProgramming What is your job??
@LucidProgramming
@LucidProgramming 4 жыл бұрын
@@simonfraile3725 You can find out all that info on my website listed in the "about" section of my channel. Cheers!
@simonfraile3725
@simonfraile3725 4 жыл бұрын
LucidProgramming ok thank you really much
@LucidProgramming
@LucidProgramming 4 жыл бұрын
@@simonfraile3725 Sure, no problem.
@janhavibhosle683
@janhavibhosle683 4 жыл бұрын
Thank you so much!!
@LucidProgramming
@LucidProgramming 4 жыл бұрын
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!
@niazahmad7823
@niazahmad7823 4 жыл бұрын
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)
@LucidProgramming
@LucidProgramming 4 жыл бұрын
I don't see how this is a better complexity. In fact, this seems to be worse than what is shown in the video.
@niazahmad7823
@niazahmad7823 4 жыл бұрын
@@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
@niazahmad7823
@niazahmad7823 4 жыл бұрын
@@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)
@LucidProgramming
@LucidProgramming 4 жыл бұрын
@@niazahmad7823 How is two loops O(n^3)? Two loops would be O(n^2).
@niazahmad7823
@niazahmad7823 4 жыл бұрын
@@LucidProgramming sir you are using two loop in function and one loop in the main that makes it O(n3)
@yt-1161
@yt-1161 2 жыл бұрын
this was interesting
@LucidProgramming
@LucidProgramming 2 жыл бұрын
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!
@moeal5110
@moeal5110 4 жыл бұрын
How can we do this recursively?
@LucidProgramming
@LucidProgramming 4 жыл бұрын
Check my recursion playlist.
@shubhamh7451
@shubhamh7451 3 жыл бұрын
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?
@LucidProgramming
@LucidProgramming 3 жыл бұрын
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).
@shubhamh7451
@shubhamh7451 3 жыл бұрын
@@LucidProgramming got it!
@titouanriot3663
@titouanriot3663 5 жыл бұрын
why do you write Len(s) ? it is an 'int' so I do not understand
@LucidProgramming
@LucidProgramming 5 жыл бұрын
No, it isn't an int. It's in between quotes and therefore treated as a string.
@jishanshaikh2003
@jishanshaikh2003 3 жыл бұрын
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??
@LucidProgramming
@LucidProgramming 3 жыл бұрын
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.
String Processing in Python: Spreadsheet Encoding
12:51
LucidProgramming
Рет қаралды 4,5 М.
From Small To Giant 0%🍫 VS 100%🍫 #katebrush #shorts #gummy
00:19
УДИВИЛ ВСЕХ СВОИМ УХОДОМ!😳 #shorts
00:49
HARD_MMA
Рет қаралды 3,5 МЛН
Hoodie gets wicked makeover! 😲
00:47
Justin Flom
Рет қаралды 138 МЛН
This Is Why Python Data Classes Are Awesome
22:19
ArjanCodes
Рет қаралды 816 М.
Sorting Algorithms in Python: Intersection of Two Sorted Arrays
12:27
LucidProgramming
Рет қаралды 9 М.
Look-and-Say Numbers (feat John Conway) - Numberphile
7:53
Numberphile
Рет қаралды 416 М.
String Processing in Python: Is Anagram
11:34
LucidProgramming
Рет қаралды 15 М.
Arrays in Python: Array Advance Game
16:55
LucidProgramming
Рет қаралды 13 М.
Sliding Window Technique - Algorithmic Mental Models
36:45
Ryan Schachte
Рет қаралды 363 М.
String Processing in Python: Check Permutation
14:32
LucidProgramming
Рет қаралды 7 М.
If __name__ == "__main__" for Python Developers
8:47
Python Simplified
Рет қаралды 415 М.
Why is Python 150X slower than C?
10:45
Mehul - Codedamn
Рет қаралды 19 М.
String Processing in Python: String to Integer
15:07
LucidProgramming
Рет қаралды 13 М.
From Small To Giant 0%🍫 VS 100%🍫 #katebrush #shorts #gummy
00:19