🚀 All of the code is available at: neetcode.io/courses/lessons/python-for-coding-interviews Timestamps: 1:13 - variables 2:40 - if-statements 4:00 - loops 6:06 - math 8:40 - arrays 12:38 - sorting 13:40 - list comprehension 14:20 - 2-d arrays 15:25 - strings 16:50 - queues 17:30 - hash sets 18:25 - hash maps 20:15 - tuples 20:55 - heaps 22:30 - functions 22:55 - nested functions 24:20 - classes
@anonforever1232 жыл бұрын
What is the theme you are using brother?
@masternobody18962 жыл бұрын
thanks
@andrewaranas88532 жыл бұрын
@NeetCode graph theory course pls.
@jeevaalok14672 жыл бұрын
@NeetCode i need a suggestion from you , i know python & c++ very well . so which one i should choose for interview purpose ? i mean which one is better ? please reply it really helps a lot
@marioamatucci Жыл бұрын
for queue I'd have mentioned something like ``` from collections import deque q = deque([1,2,3],maxlen=3) print(q) q.append(-1) print(q) q.appendleft(-2) print(q) ``` better than random op like here that does not show the queue essence :)
@JaredT8 ай бұрын
This video gives me life. If this video would ever cease to exist, I’d cry.
@perezident142 жыл бұрын
This video came out less than 12 hours after I failed to pass a coding assessment question that I did using Python. I never wrote Python code, but JS wasn’t an option for the assessment. I somehow managed to make it to the next step of the interview and I am not taking this video for granted. Thank you so much! 🎉
@rj5697 Жыл бұрын
I started to learn Python before I did a web-dev bootcamp that was just JS. I have an interview assessment where JS isn’t available and I have to use Python, and making the switch back has been…difficult lol. So I’m with you as far as not taking this video for granted lol.
@GokulPonnappanPillay10 ай бұрын
Bro how's that even possible ? What kindof questions they asked? Would be helpful to know
@NphiniT6 ай бұрын
I have interview in 15 minutes 😬
@zaboomafia4 ай бұрын
What was the coding problem you were provided?
@shelbypereira Жыл бұрын
small note: it may be mentioned in the video but really the points on "arrays" are really discussing "lists". Arrays are distinct in python and available as part of the numpy package but generally only used for situations where memory is a consideration. Also true numpy arrays cannot be resized. For a nit picking interviewer this may be important. Video is excellent , great way to cram for an interview!
@SaiManasaPappu Жыл бұрын
This video is everything I've learned about Python in the last 3 months and more! Thanks for such on-point crisp content, and for putting it all in one single video unlike other KZbinrs who make multiple never-ending clips with repetitive content
@anubhavsharma83572 жыл бұрын
Thanks!
@anujrana1509 Жыл бұрын
This is probably the best tutorial for someone who knows another programming language and wants to learn python. Thank you for the tutorial :)
@SAURABHKUMAR-uk5gg4 ай бұрын
This is the best video I have seen on using Python for anything
@macolulu2 жыл бұрын
You are a true genius. The way you display the output is so easy to see. The comments on the code are so visual. By watching your videos I started to like practicing interview questions and algorithms in general and feel sorry that I was not learning algorithms in school in the clear way that you demonstrate to us. All in all, I am grateful that I found your channel.
@meetgandhi41769 ай бұрын
At 7:09, The answer which is round off to -1 is definitely correct as -1.5 has been round to a bigger value to -1. It shows the value greater than or equal to 0.5 can be rounded off to correct value to its next greater integer value (1.5 can be rounded off to greater value 2 in positive no., and (-1.5) will be rounded off to greater value (-1) in negative no.) Yep, the explanation for it is awesome. Sometimes, its bit tricky for someone to find the particular negative value and might stuck over it. Thanks.!
@piyusharyaprakash4365 Жыл бұрын
you convinced me to change from javascript to python for coding interviews
@Kolya3578Ай бұрын
Broooo same….
@harumambaru2 жыл бұрын
Thanks, I am using python at work for more than 6 years and heaps and nested functions was new and very useful info for me. 1:23 Short addition to printing that can save you time if you do a lot of prints print(f'{n=}') is the same as print('n = ',n)
@yomanthunder18 күн бұрын
Thanks a lot for the video , this very help when you have background in c++ and planning to switch to python for problem solving and interviews
@midhunkrishnan59882 жыл бұрын
I started learning DSA with Python today and I wanted a Python refresher. as I had lost touch with it. Luckily, I came across this video and I can't believe this 26 min covered all topics. Thank you so much!
@peterwanjihia2372 Жыл бұрын
how is it going ??
@sabaamanollahi59012 жыл бұрын
Thanks NeetCode! can't wait for your system design videos :)
@streambai104511 ай бұрын
I started to learn Python about two months ago, and this is the best training video for Python.
@Lewis642 жыл бұрын
This is the best cheatsheet for python syntax ever. Got a coding interview tomorrow, thank god you posted. ❤
@picnicbros2 жыл бұрын
Used to solve most LeetCode problems using Java but thanks to you I picked up Python and agreed that it's much easier to use for interview problems where ideas are more important. This video is really helpful for me to perfect my Python skills
@Gamekiladhi79 ай бұрын
Heyy as indian can i solve dsa in python n gove job intevriew with python
@NiharikaSharma-i6v21 күн бұрын
this video is seriously amazing. it literally covers so many concepts from interview POV
@0nlypets_worldАй бұрын
10:48 not including index 3 means value 4 13:04 if u want to reverse the custom sort since default is asc but u can do? arr.sort(key=lambda x:len(x) reverse='true')
@AustinCS2 жыл бұрын
Not sure if it was mentioned or not, but for problems like path sum II it can be useful to understand deep copy vs shallow copy.
@asylzhantatibayev15382 жыл бұрын
I think the world rests on people like you. Thank you so much!!
@NeetCode2 жыл бұрын
Np 🙂
@bombrman1994 Жыл бұрын
this was so good, I was like 50% confident with my python collection skills and now I am alot more confident. I can simply google what I know that exists even if i forgot the syntax. This is what I truly need content that can show me that something exists to know what to search. We don't know what we don't know
@KrishnaDasPC7 ай бұрын
12:33 Shortest way to reverse x = [1, 2, 3, 4] print(x[::-1]) will print [4, 3, 2, 1]
@ammarh.6288Ай бұрын
This video is insane for people who've already been programming but not in python, thank you neetcode god
@soumalyadas112310 ай бұрын
6:30 - that's why, we can better say it as *floor division* 7:48 - can also be done with abs(), just in case, importing math isn't possible
@Kakashi75 Жыл бұрын
The most recent version of python released updated syntax allowing the use of increment ++ and decrement -
@ephremtadesse31956 ай бұрын
I found this tutorial to be the most precise yet packed with fascinating details! For kicks, I totally get all the Java lingo!
@sarthakgupta290 Жыл бұрын
For guys like me who are switching from Java to Python for LeetCoding, this is really helpful!
@harshivam Жыл бұрын
why you're shifting?
@sarthakgupta290 Жыл бұрын
@@harshivam Python syntax is much shorter and easier to write. I am NEVER EVER going back to Java for coding interviews
@hritikroshanmishra36309 ай бұрын
@@sarthakgupta290 is it good go in coding interview with python??????
@sarthakgupta2909 ай бұрын
@@hritikroshanmishra3630 Absolutely
@atifzia1243 ай бұрын
But in some companies they don't even mention python as an option to write code.
@535emon2 жыл бұрын
This is where I can get everything I need for coding part of my interview. Thanks Neetcode. You have given us enought
@diale13 Жыл бұрын
The best tutorial for someone who knows another programming language and wants to learn python
@ankit28goyal7 ай бұрын
This is just amazing! I always look to refresh my python syntaxes after I stop coding in this language and waste time again and again. This video is so crisp and to the point.
@nathanyao35252 жыл бұрын
this was exactly what i was looking for, thank you! Perfect timing
@imransjourneyАй бұрын
This isn't the python helper video for the interviews. This is the best recap/crash course video ever published on Python in the world.
@anselmobd Жыл бұрын
Great video! But, regarding the code shown at 6:30 of the video, I must clarify that the correct mathematical result of "-3 // 2" is "-2". This is because in the representation “Dividend = (divisor x quotient) + remainder”, the remainder must be non-negative. This is a widely accepted mathematical convention, and is useful in many applications. Thus, with the values in the example, the representation would be "-3 = (2 * -2) + 1". That said, be careful with "most languages" which are not consistent with mathematics. : )) Seriously, this may cause some error when coding some mathematical solution.
@SamyuktaNeeraj Жыл бұрын
This is such a brilliantly constructed video! Thank you so much. Could not have learned all this python I need for interviews without your help!
@md-ayaz2 жыл бұрын
All good. I use python at work. When it comes to Object oriented design interviews Java/C++ works the best. Python falls short there.
@RegularGuyJake3 ай бұрын
This video was so good! Took a ton of notes to prepare for my upcoming interview. Actually learned some very cool tricks! Didn't know that nonlocal trick, I've been just returning my data structures out of my functions and passing them around that way my whole life!
@carlossilva65792 ай бұрын
Very helpful! I studied Python a few years ago, but I didn't remember many things in this video. Thanks!
@Mizaq7 ай бұрын
7:13 int isnt really "rounding" the value. For -0,7 you would still get 0 if you make int() around it, yet the round should be -1 since its closer. Therefore int() is just deleting the values right after the dot, that in this case will be same as using math.ceil() for negative values.
@sharadrao48932 жыл бұрын
WOW 🥺 I love you ❤️ I am new to programming now I am programmer. Thanks
@mgicdood10 ай бұрын
I needed this. Ive been coding but as a game dev, and my mentor who want me to enter software development say i have to learn the Logic of Python. Thanks for this...even though im still making games on the side 😂😂
@dustinhxc Жыл бұрын
Wonderfully typed! Love the comments in the code! Thank you for this video!
@FrawkesishАй бұрын
Thanks you. This was so damn helpful ! I have been putting thiss off too long but what looked like gibberish a year ago makes a ton of sense now. 🎉
@YIXINHU-dy9gl2 ай бұрын
the most helpful video I've ever watched for python code interviews
@jeremynx4 ай бұрын
thank you. I refreshed everything in python in 26 mins
@camilailges36 Жыл бұрын
BEST video of all!! I'm also deep learning python for code interviews and this has made my life so much easier!!! Thanks so much. Your videos are the bests!
@yuurishibuya4797 Жыл бұрын
16:20 Ord() for ascii value! Nice intuitive function name, easy to remember. /s
@diegogallardo828129 күн бұрын
I just want to point out that -x % y = z is mathmatically correct. Having the remainder be a negative number is incorrect. This is because it is based on the division theorem where Divident = (Divisor x Quotient) + remainder
@entertainmentadda1183 Жыл бұрын
This video cleared alot of my small problems in for loops and lambda function. Good work brother.
@terrypark36902 жыл бұрын
Great video I've been trying to get around to learning python and this is a great brief on what's different from other coding languages saved me so much time.
@vladimirkim4112 жыл бұрын
Thank you so much! Loved how concise and clear your examples are!
@jaimelu2840 Жыл бұрын
This is a great concise yet informative summary! Thank you!
@Hamun0028 ай бұрын
Thank you for providing this, need to get back in the saddle and things like this really help
@violetjellyfish20897 ай бұрын
Отличное видео, большое спасибо! Очень удобно, что все чётко и посуществу, без длительных пауз и рассусоливаний
@Based1776 Жыл бұрын
Great video as usual, loved how concise and straight to the point it is. You've convinced me to switch from Java to Python for interviews and programming puzzles 😁
@Test-br2sm4 ай бұрын
There is a way to generate the max heaps in Python. The heapq's module has "_heapify_max" and "_heappop_max" methods. You can test it with this code: "import heapq test = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] max_heap = heap._heapify_max(test) while test: print(heapq._heappop_max(test))" I'm not sure why they created them as a protected member of the module, but this is absolutely working fine.
@ZhenglinLi Жыл бұрын
From Java to Python here! Love the concise of Python and hate we must complete 2 DSA problems in 45 min interviews.
@andiuptown171111 ай бұрын
Why hate?
@nischit72710 ай бұрын
@@andiuptown1711 probably because due to the time restriction
@Vukobratina Жыл бұрын
this is great. Thanks for your time and effort bro. Personally for me, you talk really fast, so I suggest 0.75 speed in 'runtime;. lol
@pinguincoder2 жыл бұрын
Im Not preparing for coding Interviews as im already a Software Developer in Germany. But I wan't to increase my ability To solve algorithm based Problems and my Problem solving skills in general and your Videos are absolute Gold! I'll definately will take a look into Python as im currently only working with c# which ist Kind of noisy for those Problems.
@10minutes_cs3 ай бұрын
collections can be of dynamic type , note how elements are integer , string ``` from collections import deque queue = deque() queue.append(1) queue.append("ab") queue.append(1) print(queue) mySet = set(queue) print(mySet) myMap = {} myMap["abc"] = 1 myMap[1] = "abc" print(myMap) ``` output ``` deque([1, 'ab', 1]) {1, 'ab'} {'abc': 1, 1: 'abc'} ```
@10minutes_cs3 ай бұрын
if you dont want end line ``` print("Hello", end="") print("World") ``` output : ``` HelloWorld ```
@10minutes_cs3 ай бұрын
u can add any string to end = "" , so print("Hello") is same as print("Hello", end=" ")
@akrammohamed8374 Жыл бұрын
The best video you've ever made is this one
@rajkumarv.b565 Жыл бұрын
Thanks. Thanks a lot for this. I exactly looking for whether I can use python at big tech companies. You're really awesome.
@InfiniteNesLives Жыл бұрын
Thanks for the great and concise video! One suggestion I would have is to leave some of the printouts from the examples on the screen for longer so we have time to inspect and easily pause if need be. Some of the results are on the screen for so briefly before switching to new subject that have to be ready and quick with the pause button to press. Pressing run earlier would have helped greatly while you talked instead of talking about the expected result and leaving us in unnecessary anticipation.
@TobyCrocker10 ай бұрын
Hi friend, love your channel, thank you so much for your efforts! I do have one suggestion, since you're teaching people to interview with Python, it might be helpful to follow PEP8 standards. Only interviewers with a background in Python will notice, however for experienced Python devs, not following the accepted style guidelines screams n00b which isn't ideal for interviewees trying to make a good impression. I know its a tiny detail which doesn't matter that much in the grand scheme because your channel is awesome and super helpful, however having more "Pythonic" style will definitely help junior devs put their best foot forward with more experienced Python folks.
@Ideolog-f7b2 ай бұрын
You just need to be honest with the interviewer that you use python only for coding interviews. They will understand. One only needs to learn just enough python to pass coding interviews.
@aussietramp2 жыл бұрын
New fan here. I gonna watch every single video and thumb up any of them!
@NeetCode2 жыл бұрын
Thank you 🙏
@Fahim_Ahmed22b2 жыл бұрын
This is super useful!!!! Thank you so much NeetCode!!!
@shubhadeepgoswami16333 ай бұрын
Amazing video very crisp content . Thanks for making this !!
@studywithjames7 ай бұрын
Can someone help me with 15:12 from my understanding, using "x = [0] * 3" creates [0, 0, 0], but all 0's are same object but its okay since we usually do "x[0] = 1", creating a NEW object. It is now [1, 0, 0]. But still, 0's are same object so, use the "=" sign to make NEW object. Now 2D array makes it harder. x = [[0] * 2] * 2 x[0][0] = 1 We could think that since using "=", it will only update [0][0]. But no. We are using "*" TWICE. (x = [[0] * 2] * 2). X is an object inside of an object. meaning, it will give [[1,0],[1,0]] To make a NEW object, we change the highest object. In this case, x[0] = [1, 0] thats why it sucks to use (x = [[0] * 2] * 2) in 2D array. You need to make a brand new one from scratch like x[0] = [1, 0].
@thecompanioncube4211Ай бұрын
this has screwed me so many times. Such weird thing to keep in back of your mind
@PyckledNyk8 ай бұрын
Python is also a good intro to more complex languages since it uses a lot of coding conventions that can be found in other popular languages
@dhanuufcdk2 жыл бұрын
Great video. Good for refreshing python concepts
@Eternal-j2j Жыл бұрын
arr.sort(key=lambda x:len(x)) == arr.sort(key=len) its same
@CertifiedDeadMemes Жыл бұрын
Doing an interview for a role that will primarily use python tomorrow, if I get the job, I'll subscribe to NeetCode's only fans
@NeetCode Жыл бұрын
Good luck, you got this!!!
@andiuptown171111 ай бұрын
Update
@CertifiedDeadMemes10 ай бұрын
they took forever to get back to me buy\t, yes I'm starting on Monday! @@andiuptown1711
@waiziiii4 ай бұрын
A great video for people who are already comfortable coding in other programming languages and want to learn python! Thanks man!
@nicholasscotto37123 ай бұрын
an array is a list? and a hashmap a dictionary? yes?
@gyanendravishwakarma5974Ай бұрын
Array is not a list because array stores homogeneous data type while list stores heterogeneous data type
@naturallpeace22 күн бұрын
Not exactly. Look alike for comparison. List and dict has other features also.
@_B_K_10 ай бұрын
Technically speaking, self is not a keyword in Python. You can replace it with anything else you wish.
@NeetCode10 ай бұрын
good point!
@sigfigronath Жыл бұрын
Coming from Java this syntax is so bizarre to me ahaha, great video btw !
@ahmadhawasli12944 ай бұрын
BIG thank you! ❤
@1243576891 Жыл бұрын
Very helpful. Thanks for the organization!
@amospan142 жыл бұрын
Really, really appreciate you my man! This video is exactly what I needed. Your hard work does not go unnoticed. You deserve all the recognition and praise for putting together an incredibly thoughtful and well presented Python for coding interviews video.
@moulidharanshanmugam30317 ай бұрын
at 15:16 it is said that the values would change for all the sublist when created by the format [[0]*n]*n. If the reason is that it creates the same value, then why does the other values change when I do the same with [0]*n
@m04d10y1996 Жыл бұрын
Thanks a lot for this video. Please make a video on how you learnt Java development and what resources you referred to and what was your strategy to learn and work in it.
@junaidkhankhan42605 ай бұрын
Amazing I find it hard to shift from java to python due to these kind of differences
@goodwish15432 жыл бұрын
Excellent! Hope to see more on System Design. ^_^
@seshubeshu5959 Жыл бұрын
@NeetCode I really appreciate the quick refresher on python. I used it back in grad school and never touched it again. Would it be possible to break down every topic into an individual video that can be maintained as a playlist ? I may not be the sharpest tool in the box, however, it feels like certain sections of the current video are little fast.
@Sgoose105 Жыл бұрын
it'd better call [1, 2, 3] as list, as oppposed to an array. I think array refers to numpy array
@alexandretrajano89279 ай бұрын
Thanks man, you helped me a lot! Damn useful!
@congwang171 Жыл бұрын
Thank you so much. This video helps me a lot.
@silent71522 жыл бұрын
exaaclty what i needed ... thanks man
@ding88802 жыл бұрын
Yo just want to let you know that I can't afford the paid version now. But someday in the future when I have a better job imma buy a few and gift others as a token of appreciation.
@SaravananD5 ай бұрын
Brilliant as usual 🙂
@practicefirsttheorylater Жыл бұрын
perfect video for a longtime java user like me
@mnchester2 жыл бұрын
Great video! Still seems unreal that there's no native way to support a max-heap without that awkward workaround. I was expecting better from Python :)
@prithvivenkatesh3276 ай бұрын
Hi! 15:13 - can this part be explained in detail? By the way, thanks much for the amazing content you share!
@sreelekhabasina27918 ай бұрын
Best best best❤
@luisroxjimenez2 жыл бұрын
This video helped a lot, thank you.
@youpremium1755 ай бұрын
OMG YOU ARE A LIFESAVER
@SushmithaSathyanarayanan-u4l5 ай бұрын
How do u juggle between different languages? I might end up googling built in libraries if I juggle, which is not good for interviews
@NG-bd6di2 жыл бұрын
Regarding the 2d arrays tip @15:16: Could you provide an example of how the "wrong" method would become an issue? I understand that it's basically 4 "clone" rows of zeros, rather than unique rows. But messing around with both methods, I can't get figure out when this difference would become a problem. Thanks!
@NeetCode2 жыл бұрын
If you were using it to store information, if you update one row it will update all of the rows in the same position. This would be troublesome for DP problems or graph problems.
@BrunoBAlt-n4h10 ай бұрын
you can use .copy() tho
@__sarik2 жыл бұрын
Please also make a video regarding bisect function of py, it is also very useful. And also I have a question regarding heapq, what we should do if we want to have customized sorting?
@ilatif_bwp2 жыл бұрын
Me before watching the video: Python is a snake Me after watching the video: I've learned years worth of Python in mere 30 minutes and would be using Python for solving coding problems from now on (my primary programming language has been JavaScript for years)