Python for Coding Interviews - Everything you need to Know

แชร์
ฝัง
  • เผยแพร่เมื่อ 20 พ.ย. 2024

ความคิดเห็น • 303

  • @NeetCode
    @NeetCode  2 ปีที่แล้ว +88

    🚀 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

    • @anonforever123
      @anonforever123 2 ปีที่แล้ว

      What is the theme you are using brother?

    • @masternobody1896
      @masternobody1896 2 ปีที่แล้ว

      thanks

    • @andrewaranas8853
      @andrewaranas8853 2 ปีที่แล้ว +1

      @NeetCode graph theory course pls.

    • @jeevaalok1467
      @jeevaalok1467 ปีที่แล้ว

      @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
      @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 :)

  • @JaredT
    @JaredT 7 หลายเดือนก่อน +19

    This video gives me life. If this video would ever cease to exist, I’d cry.

  • @perezident14
    @perezident14 2 ปีที่แล้ว +403

    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
      @rj5697 ปีที่แล้ว +8

      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.

    • @GokulPonnappanPillay
      @GokulPonnappanPillay 9 หลายเดือนก่อน +3

      Bro how's that even possible ? What kindof questions they asked? Would be helpful to know

    • @NphiniT
      @NphiniT 5 หลายเดือนก่อน +2

      I have interview in 15 minutes 😬

    • @zaboomafia
      @zaboomafia 3 หลายเดือนก่อน

      What was the coding problem you were provided?

  • @shelbypereira
    @shelbypereira ปีที่แล้ว +28

    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
    @SaiManasaPappu ปีที่แล้ว +33

    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 TH-camrs who make multiple never-ending clips with repetitive content

  • @anujrana1509
    @anujrana1509 ปีที่แล้ว +53

    This is probably the best tutorial for someone who knows another programming language and wants to learn python. Thank you for the tutorial :)

    • @SAURABHKUMAR-uk5gg
      @SAURABHKUMAR-uk5gg 3 หลายเดือนก่อน

      This is the best video I have seen on using Python for anything

  • @macolulu
    @macolulu ปีที่แล้ว +51

    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.

  • @imransjourney
    @imransjourney 9 วันที่ผ่านมา +1

    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.

  • @piyusharyaprakash4365
    @piyusharyaprakash4365 ปีที่แล้ว +14

    you convinced me to change from javascript to python for coding interviews

    • @Kolya3578
      @Kolya3578 17 วันที่ผ่านมา

      Broooo same….

  • @meetgandhi4176
    @meetgandhi4176 8 หลายเดือนก่อน

    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.!

  • @harumambaru
    @harumambaru 2 ปีที่แล้ว +11

    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)

  • @Lewis64
    @Lewis64 2 ปีที่แล้ว +9

    This is the best cheatsheet for python syntax ever. Got a coding interview tomorrow, thank god you posted. ❤

  • @ephremtadesse3195
    @ephremtadesse3195 5 หลายเดือนก่อน +1

    I found this tutorial to be the most precise yet packed with fascinating details! For kicks, I totally get all the Java lingo!

  • @ammarh.6288
    @ammarh.6288 หลายเดือนก่อน

    This video is insane for people who've already been programming but not in python, thank you neetcode god

  • @streambai1045
    @streambai1045 10 หลายเดือนก่อน +1

    I started to learn Python about two months ago, and this is the best training video for Python.

  • @midhunkrishnan5988
    @midhunkrishnan5988 2 ปีที่แล้ว +47

    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!

  • @diale13
    @diale13 ปีที่แล้ว

    The best tutorial for someone who knows another programming language and wants to learn python

  • @AustinCS
    @AustinCS 2 ปีที่แล้ว +15

    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.

  • @ankit28goyal
    @ankit28goyal 6 หลายเดือนก่อน

    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.

  • @picnicbros
    @picnicbros ปีที่แล้ว +22

    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

    • @Gamekiladhi7
      @Gamekiladhi7 8 หลายเดือนก่อน +1

      Heyy as indian can i solve dsa in python n gove job intevriew with python

  • @asylzhantatibayev1538
    @asylzhantatibayev1538 ปีที่แล้ว +18

    I think the world rests on people like you.
    Thank you so much!!

  • @Kakashi75
    @Kakashi75 ปีที่แล้ว +4

    The most recent version of python released updated syntax allowing the use of increment ++ and decrement -

  • @bombrman1994
    @bombrman1994 ปีที่แล้ว +2

    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

  • @sabaamanollahi5901
    @sabaamanollahi5901 2 ปีที่แล้ว +23

    Thanks NeetCode! can't wait for your system design videos :)

  • @535emon
    @535emon 2 ปีที่แล้ว +5

    This is where I can get everything I need for coding part of my interview. Thanks Neetcode. You have given us enought

  • @diegogallardo8281
    @diegogallardo8281 วันที่ผ่านมา

    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

  • @jeremynx
    @jeremynx 3 หลายเดือนก่อน

    thank you. I refreshed everything in python in 26 mins

  • @RegularGuyJake
    @RegularGuyJake 2 หลายเดือนก่อน

    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!

  • @SamyuktaNeeraj
    @SamyuktaNeeraj ปีที่แล้ว +3

    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!

  • @sarthakgupta290
    @sarthakgupta290 ปีที่แล้ว +2

    For guys like me who are switching from Java to Python for LeetCoding, this is really helpful!

    • @harshivam
      @harshivam ปีที่แล้ว

      why you're shifting?

    • @sarthakgupta290
      @sarthakgupta290 ปีที่แล้ว +4

      @@harshivam Python syntax is much shorter and easier to write. I am NEVER EVER going back to Java for coding interviews

    • @hritikroshanmishra3630
      @hritikroshanmishra3630 8 หลายเดือนก่อน

      @@sarthakgupta290 is it good go in coding interview with python??????

    • @sarthakgupta290
      @sarthakgupta290 8 หลายเดือนก่อน

      @@hritikroshanmishra3630 Absolutely

    • @atifzia124
      @atifzia124 2 หลายเดือนก่อน

      But in some companies they don't even mention python as an option to write code.

  • @0nlypets_world
    @0nlypets_world 9 วันที่ผ่านมา

    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')

  • @nathanyao3525
    @nathanyao3525 2 ปีที่แล้ว +8

    this was exactly what i was looking for, thank you! Perfect timing

  • @anselmobd
    @anselmobd ปีที่แล้ว +1

    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.

  • @carlossilva6579
    @carlossilva6579 หลายเดือนก่อน

    Very helpful! I studied Python a few years ago, but I didn't remember many things in this video. Thanks!

  • @Test-br2sm
    @Test-br2sm 3 หลายเดือนก่อน

    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.

  • @nicholasscotto3712
    @nicholasscotto3712 2 หลายเดือนก่อน +8

    an array is a list? and a hashmap a dictionary? yes?

    • @gyanendravishwakarma5974
      @gyanendravishwakarma5974 27 วันที่ผ่านมา

      Array is not a list because array stores homogeneous data type while list stores heterogeneous data type

  • @YIXINHU-dy9gl
    @YIXINHU-dy9gl หลายเดือนก่อน

    the most helpful video I've ever watched for python code interviews

  • @PyckledNyk
    @PyckledNyk 7 หลายเดือนก่อน

    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

  • @KrishnaDasPC
    @KrishnaDasPC 6 หลายเดือนก่อน

    12:33
    Shortest way to reverse
    x = [1, 2, 3, 4]
    print(x[::-1])
    will print
    [4, 3, 2, 1]

  • @InfiniteNesLives
    @InfiniteNesLives ปีที่แล้ว +1

    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.

  • @yuurishibuya4797
    @yuurishibuya4797 ปีที่แล้ว +1

    16:20 Ord() for ascii value! Nice intuitive function name, easy to remember. /s

  • @soumalyadas1123
    @soumalyadas1123 9 หลายเดือนก่อน

    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

  • @sharadrao4893
    @sharadrao4893 2 ปีที่แล้ว +1

    WOW 🥺 I love you ❤️
    I am new to programming now I am programmer. Thanks

  • @md-ayaz
    @md-ayaz 2 ปีที่แล้ว +1

    All good. I use python at work. When it comes to Object oriented design interviews Java/C++ works the best. Python falls short there.

  • @adamrizk6735
    @adamrizk6735 ปีที่แล้ว +3

    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 😁

  • @dustinhxc
    @dustinhxc ปีที่แล้ว +2

    Wonderfully typed! Love the comments in the code! Thank you for this video!

  • @Hamun002
    @Hamun002 7 หลายเดือนก่อน

    Thank you for providing this, need to get back in the saddle and things like this really help

  • @mgicdood
    @mgicdood 9 หลายเดือนก่อน

    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 😂😂

  • @seshubeshu5959
    @seshubeshu5959 ปีที่แล้ว +5

    @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.

  • @ZhenglinLi
    @ZhenglinLi ปีที่แล้ว +1

    From Java to Python here! Love the concise of Python and hate we must complete 2 DSA problems in 45 min interviews.

    • @andiuptown1711
      @andiuptown1711 10 หลายเดือนก่อน +1

      Why hate?

    • @nischit727
      @nischit727 9 หลายเดือนก่อน

      ​@@andiuptown1711 probably because due to the time restriction

  • @jaimelu2840
    @jaimelu2840 ปีที่แล้ว +2

    This is a great concise yet informative summary! Thank you!

  • @camilailges36
    @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!

  • @Frawkesish
    @Frawkesish 12 วันที่ผ่านมา

    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. 🎉

  • @entertainmentadda1183
    @entertainmentadda1183 ปีที่แล้ว +1

    This video cleared alot of my small problems in for loops and lambda function. Good work brother.

  • @terrypark3690
    @terrypark3690 2 ปีที่แล้ว +3

    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.

  • @Mizaq
    @Mizaq 6 หลายเดือนก่อน

    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.

  • @vladimirkim411
    @vladimirkim411 2 ปีที่แล้ว +4

    Thank you so much! Loved how concise and clear your examples are!

  • @CertifiedDeadMemes
    @CertifiedDeadMemes 11 หลายเดือนก่อน +2

    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
      @NeetCode  11 หลายเดือนก่อน +1

      Good luck, you got this!!!

    • @andiuptown1711
      @andiuptown1711 10 หลายเดือนก่อน +1

      Update

    • @CertifiedDeadMemes
      @CertifiedDeadMemes 10 หลายเดือนก่อน

      they took forever to get back to me buy\t, yes I'm starting on Monday! @@andiuptown1711

  • @_B_K_
    @_B_K_ 9 หลายเดือนก่อน +2

    Technically speaking, self is not a keyword in Python. You can replace it with anything else you wish.

    • @NeetCode
      @NeetCode  9 หลายเดือนก่อน

      good point!

  • @junaidkhankhan4260
    @junaidkhankhan4260 4 หลายเดือนก่อน +1

    Amazing
    I find it hard to shift from java to python due to these kind of differences

  • @Vukobratina
    @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

  • @pinguincoder
    @pinguincoder 2 ปีที่แล้ว

    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.

  • @TobyCrocker
    @TobyCrocker 9 หลายเดือนก่อน

    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-f7b
      @Ideolog-f7b หลายเดือนก่อน

      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.

  • @akrammohamed8374
    @akrammohamed8374 11 หลายเดือนก่อน

    The best video you've ever made is this one

  • @rajkumarv.b565
    @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.

  • @aussietramp
    @aussietramp 2 ปีที่แล้ว

    New fan here. I gonna watch every single video and thumb up any of them!

    • @NeetCode
      @NeetCode  2 ปีที่แล้ว

      Thank you 🙏

  • @Eternal-j2j
    @Eternal-j2j ปีที่แล้ว +1

    arr.sort(key=lambda x:len(x)) == arr.sort(key=len)
    its same

  • @amospan14
    @amospan14 2 ปีที่แล้ว +14

    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.

  • @shubhadeepgoswami1633
    @shubhadeepgoswami1633 2 หลายเดือนก่อน

    Amazing video very crisp content . Thanks for making this !!

  • @violetjellyfish2089
    @violetjellyfish2089 6 หลายเดือนก่อน

    Отличное видео, большое спасибо! Очень удобно, что все чётко и посуществу, без длительных пауз и рассусоливаний

  • @10minutes_cs
    @10minutes_cs 2 หลายเดือนก่อน

    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_cs
      @10minutes_cs 2 หลายเดือนก่อน

      if you dont want end line
      ```
      print("Hello", end="")
      print("World")
      ```
      output :
      ```
      HelloWorld
      ```

    • @10minutes_cs
      @10minutes_cs 2 หลายเดือนก่อน

      u can add any string to end = "" ,
      so print("Hello") is same as print("Hello", end="
      ")

  • @mnchester
    @mnchester 2 ปีที่แล้ว

    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 :)

  • @m04d10y1996
    @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.

  • @ding8880
    @ding8880 2 ปีที่แล้ว +1

    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.

  • @Sgoose105
    @Sgoose105 ปีที่แล้ว

    it'd better call [1, 2, 3] as list, as oppposed to an array. I think array refers to numpy array

  • @sigfigronath
    @sigfigronath ปีที่แล้ว +1

    Coming from Java this syntax is so bizarre to me ahaha, great video btw !

  • @Fahim_Ahmed22b
    @Fahim_Ahmed22b 2 ปีที่แล้ว +1

    This is super useful!!!! Thank you so much NeetCode!!!

  • @waiziiii
    @waiziiii 3 หลายเดือนก่อน

    A great video for people who are already comfortable coding in other programming languages and want to learn python! Thanks man!

  • @dhanuufcdk
    @dhanuufcdk 2 ปีที่แล้ว +2

    Great video. Good for refreshing python concepts

  • @DodoLP
    @DodoLP 2 ปีที่แล้ว

    the modulo and minus modulo is because of how its mathematically written

  • @prithvivenkatesh327
    @prithvivenkatesh327 5 หลายเดือนก่อน

    Hi!
    15:13 - can this part be explained in detail?
    By the way, thanks much for the amazing content you share!

  • @Chris-qb6lb
    @Chris-qb6lb 6 หลายเดือนก่อน +1

    Python: Use and instead of &&, but use str() instead of string()

  • @Migsfigs
    @Migsfigs ปีที่แล้ว

    Great video. Did you touch on linked lists? I might've missed it.

  • @practicefirsttheorylater
    @practicefirsttheorylater ปีที่แล้ว

    perfect video for a longtime java user like me

  • @goodwish1543
    @goodwish1543 2 ปีที่แล้ว +1

    Excellent! Hope to see more on System Design. ^_^

  • @1243576891
    @1243576891 ปีที่แล้ว

    Very helpful. Thanks for the organization!

  • @__sarik
    @__sarik 2 ปีที่แล้ว +1

    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?

  • @anubhavsharma8357
    @anubhavsharma8357 2 ปีที่แล้ว +15

    Thanks!

  • @mukeshnayal624
    @mukeshnayal624 ปีที่แล้ว

    nice content ! will you make it for advance questions.

  • @ahmadhawasli1294
    @ahmadhawasli1294 3 หลายเดือนก่อน +1

    BIG thank you! ❤

  • @KannanMavila
    @KannanMavila 2 ปีที่แล้ว

    Really good list. Love how concise it is.
    You missed something important though: taking input from file and from console

  • @congwang171
    @congwang171 ปีที่แล้ว

    Thank you so much. This video helps me a lot.

  • @alexandretrajano8927
    @alexandretrajano8927 8 หลายเดือนก่อน

    Thanks man, you helped me a lot! Damn useful!

  • @rhinelandnagel7288
    @rhinelandnagel7288 10 ชั่วโมงที่ผ่านมา

    Doing God's work right here

  • @studywithjames
    @studywithjames 6 หลายเดือนก่อน +2

    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
      @thecompanioncube4211 5 วันที่ผ่านมา

      this has screwed me so many times. Such weird thing to keep in back of your mind

  • @Jkfgjfgjfkjg
    @Jkfgjfgjfkjg 7 หลายเดือนก่อน

    I think by “appending” strings together you mean “concatenate”.

  • @luisroxjimenez
    @luisroxjimenez ปีที่แล้ว

    This video helped a lot, thank you.

  • @oshogarg5215
    @oshogarg5215 9 หลายเดือนก่อน

    Can you please make more videos similar to this for Python , thanks

  • @dera_ng
    @dera_ng 2 ปีที่แล้ว +3

    Great video! I definitely learnt new stuff too 🙂. I'll like to just note a couple of things here.
    In Python, the actual constructor is __new__(cls, *args, **kwargs) while the initialiser function is __init__(self, *args, **kwargs). And you can totally do else if: in one line as it's equivalent to elif:
    Regardless, amazing as always! Thanks neetCode!

  • @marinablue9903
    @marinablue9903 2 ปีที่แล้ว

    Hi NeetCode, I'm wondering why your video about your internship experience at Capital One is not available now? That video was very interesting and wanted to see again since I got an offer from Capital One for TIP! Hope I can see that video again :)