Solve This Coding Problem and Win $200

Sdílet
Vložit
  • čas přidán 18. 07. 2021
  • Get in touch with me in my free software developer community: www.skool.com/software-develo...
    📚 Free 0 to Full-Time Programmer in 5 Steps eBook: kgunderman.com/newsletter
    @NickWhite and I hit the streets of Chicago to ask strangers If they know how to write code. If they do, and they're able to solve our programming challenges we will give them up to $200.
    Subscribe to Nick's CZcams channel:
    czcams.com/users/nickwhite?sub...
    Business Inquiries:
    contact@kgunderman.com
    Resources:
    ----------------------------------------------------------------------------
    My Top Recommended Udemy Courses: bit.ly/3miUBbm
    Skillshare: skl.sh/kennygunderman07211
    Socials:
    ----------------------------------------------------------------------------
    Subscribe: / kennygunderman
    Instagram: / kennygunderman
    Twitter: / kennygunderman
  • Věda a technologie

Komentáře • 2,4K

  • @godofpro5767
    @godofpro5767 Před 2 lety +20988

    a real programmer won’t go outside

  • @secabrepheox5450
    @secabrepheox5450 Před 2 lety +4342

    6:11 "It's never too early to start coding"..
    I've been telling my 3 year old kid that but she insists on learning how to read first... Kids these days..

  • @emachine003
    @emachine003 Před rokem +94

    The funny thing about 0:52 is that her solution of using reversed() is actually far more efficient than manually writing out a function to reverse the string since Python library functions are highly optimized.

    • @meelaud2103
      @meelaud2103 Před rokem +33

      no shit XDDD thats y she couldnt use it

    • @apostate101
      @apostate101 Před rokem +7

      You're right, Since Python is written in C, the library functions are super fast.

    • @bronzejourney5784
      @bronzejourney5784 Před rokem +24

      @@meelaud2103 But thats not a right mindset to be a programmer with, especially in today's market. What looks like cheating to you is just another tuesday for us. It just works like that, as said "You dont need to reinvent the wheel everytime you need to go somewhere with your car".

    • @joaofernandes6419
      @joaofernandes6419 Před rokem +1

      Recursivity always calling the function + char of the current position until the length of the string would work well too

    • @trash_in_a_box
      @trash_in_a_box Před rokem +1

      @@bronzejourney5784 She wasn't the one making up the rules. And honestly, there is a lot to be learned by trying to accomplish something in as many different ways as possible, rather than calling it good with the "easy" or "correct" way.

  • @Bayers2020
    @Bayers2020 Před 2 lety +555

    The guy at the end said
    “I think it’s an essential skill everyone should have.”
    I cannot agree more.
    I’ve discounted myself for years as dumb or not learned because I’ve never delved into things like this which have always put me in awe and today I realized, when time applied, I could actually do this if I wanted to, and how far progressed would we be technologically if everyone had this under their belt from a young age xD

    • @sudonim116
      @sudonim116 Před 2 lety +31

      Issue is not everyone enjoys it

    • @mtutoriales
      @mtutoriales Před rokem +9

      So is math yet so many people hate it with passion regardless of their potential.

    • @TheAnimeist
      @TheAnimeist Před rokem +3

      I feel the same way about boards. Everyone should at least skateboard, surf, Onewheel, etc. Progress toward peace and no hunger, imagine it xD

    • @angelsaucedo2231
      @angelsaucedo2231 Před rokem +1

      bruh nothing is hard if you apply yourself. Its just memorizing things. Like advanced maths. Just some people dont care to learn

    • @uku4171
      @uku4171 Před rokem +5

      @@mtutoriales I think it mostly depends on the teacher. It's also because of the reputation that maths has as "the hard subject".

  • @danielgeorgianni1687
    @danielgeorgianni1687 Před 2 lety +2492

    "In java it doesnt work"
    Man rethought his existence in .5 second 🤣🤣

    • @ericjohn2352
      @ericjohn2352 Před 2 lety +82

      Hahaha "Why am I here, What purpose do I have"

    • @putramakatita8814
      @putramakatita8814 Před 2 lety +19

      Hey! 🤣

    • @dgh25
      @dgh25 Před 2 lety +10

      i did this in java in 5 mins

    • @Omar-kl3xp
      @Omar-kl3xp Před 2 lety +14

      In Java it would be easy for me to do it however I don’t knw any other programming language yet

    • @iamgroot1328
      @iamgroot1328 Před 2 lety +1

      I know python the easiest one

  • @stxnw
    @stxnw Před 2 lety +7619

    i am starting to think im better than the average programmer after watching this. might be a sampling bias since better programmers dont leave the house.

    • @soruzein2988
      @soruzein2988 Před 2 lety +155

      they fear to the sun

    • @stxnw
      @stxnw Před 2 lety +114

      just want everybody to know that i am all green on my github

    • @mohitsagar9492
      @mohitsagar9492 Před 2 lety +89

      lol I cringed hard when I saw the first girl using "+=" with a string in Python (since strings are immutable in Python, it basically creates a new string every time making the complexity O(N^2)).

    • @stxnw
      @stxnw Před 2 lety +72

      @@mohitsagar9492 if im not wrong string concatenation are ammortized O(1) just like push_back() in C++ without reserve(). either way, it should be a non issue nowadays. there were more... pressing mistakes.. in the video.

    • @mohitsagar9492
      @mohitsagar9492 Před 2 lety +37

      @@stxnw Right in C++ strings are mutable! However in Python and Java they are immutable. Honestly everyone other than the first girl and that one Indian dude with Hashmaps didn't seem to be actual programmers so I didn't expect much from them anyway XD. And you will be surprised how much these small optimizations can matter when dealing with massive data!

  • @brownbearedurardo
    @brownbearedurardo Před rokem +11

    I'm a 3rd-year Computer Engineering student and this video makes me wanna refresh my knowledge in programming (both C and C++). Love from the Philippines.

  • @kaiacrisp
    @kaiacrisp Před 2 lety +151

    Dude I watched this like 6 months ago and didn't know how they did any of this but after taking a CS class in Python I understand it now. Thats insane...

    • @momenmohamed8337
      @momenmohamed8337 Před 2 lety +2

      in what U toke it

    • @IllIIIIIIllll
      @IllIIIIIIllll Před rokem +6

      same here,that hits different

    • @kaiacrisp
      @kaiacrisp Před rokem +1

      @@momenmohamed8337 in a intro to CS college class

    • @vanci2039
      @vanci2039 Před rokem +1

      If a online class drop the link

    • @dv5625
      @dv5625 Před rokem

      @@vanci2039 czcams.com/video/JP7ITIXGpHk/video.html

  • @clucl3
    @clucl3 Před 2 lety +4100

    When grandpa comes out swinging like, "binary, assembly, matlab, basic, that's what I used to use when I was a kid"

  • @Zordiak
    @Zordiak Před 2 lety +454

    "What language do you program in?"
    Old guy: Punch cards

    • @kennygunderman
      @kennygunderman  Před 2 lety +28

      Lmao

    • @ingiford175
      @ingiford175 Před 2 lety +31

      Remember doing my final exam for Cobal on punch cards. Program was due before the 2 hour final (2 week assignment). The final exam, he took all our programs, and dropped them on the floor and told us to reassemble our program.

    • @delaseadom6800
      @delaseadom6800 Před 2 lety +4

      I'm crying😭😭😭🤣🤣🤣🤣🤣

    • @piaoyugexia
      @piaoyugexia Před rokem

      @@ingiford175 EEP!

    • @ashwin-7777
      @ashwin-7777 Před rokem

      🤣

  • @ab.5
    @ab.5 Před rokem +12

    grandpa still remembers Fortran 💀 3:25

  • @qmance8062
    @qmance8062 Před rokem +94

    I watched this video for the first time a year ago. I had no idea what they were even talking about. Now a year later, i know exactly whats going on and im able to solve pretty much every problem. It feels nice to see progress.

    • @Itsmebieno
      @Itsmebieno Před rokem

      I want to do so

    • @Gupatik
      @Gupatik Před rokem

      same here

    • @NostalgicMems
      @NostalgicMems Před 11 měsíci

      Woah for real? What helped you achieve that

    • @filyboy7
      @filyboy7 Před 10 měsíci +1

      same here! i'm on day 20 of angela yu's 100 days of code on udemy, and i was able to solve every question in the video 😁

    • @Broketechbro
      @Broketechbro Před 10 měsíci +1

      @@filyboy7I am also studying that course 😊

  • @Quimerateck
    @Quimerateck Před 2 lety +301

    after finishing a course in python programing, i feel prepared to write my print('hello world')

  • @uyscuti5571
    @uyscuti5571 Před 2 lety +42

    man at 3:37 is like : C , C# ,C+,C++,C+++,C x max pro ,C lite

  • @Rakeshyadav-ud8di
    @Rakeshyadav-ud8di Před 2 lety +11

    It's great work done by you and for those who are starting career in IT.

  • @Michael89312
    @Michael89312 Před 4 měsíci

    A good solution for two sum is two pointers.
    We have a variable init to 0 to track current total.
    Left and right variables track from the start and end of the array.
    We check if left index element + right element index == sum, if so return it and break out of the function.
    If not
    We use a while loop, while total != sum and conditionals that ask if total is > or < sum. If > move the right pointer to the left and if < move left pointer to the right.
    Either we get a match for sum via two indices or
    If we check the entire array and there's no match, have a return outside the while loop to return a meaningful message to the user.

  • @NickWhite
    @NickWhite Před 2 lety +3180

    i think we might be giving money to people that don't really need it...

  • @Landon_Hughes
    @Landon_Hughes Před 2 lety +610

    3:37 didn't know "C+" was a programming language 🤔

    • @Spero_Hawk
      @Spero_Hawk Před 2 lety +124

      It came around the same time as C Flat.

    • @mesh3218
      @mesh3218 Před 2 lety +47

      The son of c++ is c+😀😀😀😀😀😀

    • @mariop4211
      @mariop4211 Před 2 lety +40

      Lol that’s me! I panicked

    • @atti1120
      @atti1120 Před 2 lety +25

      Family with C hashtag

    • @user-tk2jy8xr8b
      @user-tk2jy8xr8b Před 2 lety +36

      Maybe he designed it himself, you can never be sure

  • @mmiselodlephu3669
    @mmiselodlephu3669 Před rokem +2

    First time I watched this video was before I started coding and I had no idea what's happening. I just returned to see how far I've come. It's unbelievable how far I've come in 5 months

  • @ivandumancic2938
    @ivandumancic2938 Před rokem +7

    Q: name 4 programming languages.
    Guy at 3:45
    A: java (0), python (1), javascript (2), c (3), ruby (4)

  • @elephantwaffle5612
    @elephantwaffle5612 Před 2 lety +1791

    I nervously watched and attempted the problems being a recent Computer Science graduate (thinking that I wouldn't know and would feel stupid). I learned that I can at least answer simple coding problems! Thanks 4 years of college!

    • @nickfleming3719
      @nickfleming3719 Před 2 lety +47

      Yeah but, you spent 4 years and $40,000+ to learn what anybody can learn for free on CZcams in a couple months.
      And in another 4 years, everything you did learn will be obsolete, but you'll still be paying for it.

    • @elephantwaffle5612
      @elephantwaffle5612 Před 2 lety +50

      @@nickfleming3719 instate public college + athletic scholarships + academic scholarships + college isn’t really all about what you learn in your courses + computer science isn’t just being good a programming + L + ur white

    • @lva98
      @lva98 Před 2 lety +148

      @@nickfleming3719 Computer Science is not about programming or been a programmer

    • @nickfleming3719
      @nickfleming3719 Před 2 lety +10

      @@elephantwaffle5612 ok I see why you needed it

    • @elephantwaffle5612
      @elephantwaffle5612 Před 2 lety +236

      @@nickfleming3719 imagine watching a few “how to code” vids on CZcams and then feeling superior enough to make fun of someone for getting a BS in computer science

  • @sketchturner6669
    @sketchturner6669 Před 2 lety +6

    5:35 my nigga even doin the exception handling

  • @bradleyhastings2422
    @bradleyhastings2422 Před 2 lety

    The two sum could be done iterating 0

  • @heat-rp1gm
    @heat-rp1gm Před 2 lety +6

    Amazing video as usual, keep up the fantastic content, your videos always make my day, thanks, I love the positive vibes, keep it up !!!

  • @arpanghoshal2579
    @arpanghoshal2579 Před 2 lety +31

    2:06 Does it matter what language?
    Nah
    *Processed to write machine code in 0s and 1s*

  • @ahmadmohamad8416
    @ahmadmohamad8416 Před 2 lety +16

    2:20 hey heeeeeeeeeey lmao

  • @luckyambitiousnthani2848
    @luckyambitiousnthani2848 Před 2 lety +4

    Keep this kind of videos coming man.
    Very inspiring

  • @pomodoro3478
    @pomodoro3478 Před rokem +4

    5:20 this challenge can be solve just by using 2 indexes and a for loop to scan the array 1 time since it's ordered

    • @maniakos_
      @maniakos_ Před rokem +2

      You can do it with one index as well

  • @Sad-Lemon
    @Sad-Lemon Před 2 lety +495

    An idea: After each question you show the optimal solution and why is it optimal.
    I interviewed like dozens of programmers and one thing to learn as an interviewer - help the programmer to know what mistake he/she made. We don't want to keep people doing the same errors over and over again. This is counterproductive for the industry.

    • @arkesh110
      @arkesh110 Před rokem +2

      Yeah for the last one, I thought the solution would just be to use a double for loop and an if statement to find the sum of all the combinations and then just return whatever is at those indexes

    • @bobfarker4001
      @bobfarker4001 Před rokem +1

      I feel that way too, but you're asking people on the spot in the street. Without an ide I can't weed out the syntax errors.

    • @sid6693
      @sid6693 Před rokem

      @@arkesh110 double for loop is too slow you can do it using 1 and having a set to keep track of the elements you found already

    • @MyAmazingUsername
      @MyAmazingUsername Před 10 měsíci +4

      5:40 He has some typos and syntax errors but the overall concept is great. It makes a dict map of "which remainder maps to the current number". And as soon as it encounters that remainder as a unique number, the dict returns the complementary number that sums with it. Good job coming up with that on the spot.

    • @bobfarker4001
      @bobfarker4001 Před 10 měsíci

      @@MyAmazingUsername shut up. You're just rehashing what I said with a positive spin.

  • @rbt-0007
    @rbt-0007 Před 2 lety +174

    Wish I was there, literally free money for every single question.

  • @dave_thebrave
    @dave_thebrave Před rokem

    so glad to know! you're going to explain things to me, and appreciate the

  • @emachine003
    @emachine003 Před rokem +3

    I have a CS exam today, and I'm practicing for the coding problems by going through and doing each problem in Java. Thanks for this video!

    • @johndorian4078
      @johndorian4078 Před rokem

      if these problems are your practice............................... good luck.

    • @emachine003
      @emachine003 Před rokem

      @@johndorian4078 took the exam already. It was kind of hard, but not that bad. Honestly, I was more following along for fun than actually preparing for the exam.

  • @djaberomarkahlouche6342
    @djaberomarkahlouche6342 Před 2 lety +66

    this's a great video , at least you motivate some people to learn coding and don't see coding is a impossible mission. Great video , keep going

    • @samanmehralipoor9773
      @samanmehralipoor9773 Před 2 lety +2

      programming languages are easy to learn but becoming a professional developer is not.
      so I think it's not ok to say everyone "come on start to learning programming".

  • @ayubhaji2441
    @ayubhaji2441 Před 2 lety +33

    That first girl solution was nice, I been around your channel around the past but this is the first time seeing you do these videos. It's been a while since I solve some problems, these videos awake that feeling in me again.😁

  • @micknamens8659
    @micknamens8659 Před 2 lety

    -- sum2d in Haskell with standard Prelude function 'foldl' :
    sum2d = foldl (foldl (+)) 0
    -- outputting the sample result:
    main = putStr $ show $ sum2d [[1, 2, 3],[4, 5]]

  • @hanac5586
    @hanac5586 Před rokem

    You met such nice people, wholesome

  • @KhainiSader
    @KhainiSader Před 2 lety +494

    would've have been more interesting, if you asked them to just walk it through instead of writing code. This way you can find people who have no clue of coding but have natural design/engineering skills. This would also require you to re-arrange the question for better understanding. Cool :D

    • @WoWkiddymage
      @WoWkiddymage Před 2 lety +64

      That's kinda hard if you don't really understand the basic ruleset that programming provides (ways data/variables are stored, and ways to compare them). But I also think it would be a really good idea.

    • @mk177
      @mk177 Před 2 lety +5

      if you don't know anything about coding and the language they cannot test for anything imho obv. analogy here but would a racecardriver prove his talent if he hasn't touched go-karts at a young age. I have been good at math all my life, went up to AP Calc/Passed, but first time I saw a for loop iteration I was astounded, maybe makes it easier to understand after you have seen it but most of coding algos and components making them are kind of like magic tricks, you will need practice (alot) to understand how they are done. My .02

    • @minhuang8848
      @minhuang8848 Před 2 lety +3

      @@WoWkiddymage But that's the point, everyone does coding. Everyone who has learned how to manually calculate the root of a given number is pretty much primed to code in their heads, programming is just an abstraction layer to offload strict calculations while the programmer conceptualizes the steps. And yeah, definitely a dope idea, anything to get people involved who didn't think they were suited for it. Maybe some kind of paid bootcamp next where people just get money for learning a basic curriculum, that'd be fun too.

    • @WoWkiddymage
      @WoWkiddymage Před 2 lety +8

      @@minhuang8848 What I'm saying is that these algorithm-based questions are created with restraints that you only understand if you have programmed before. Yes, coding/programming is "just" an abstraction but that is often the difficult part about it. Putting these concepts into the limits of programming data structures and being restricted by time complexities. I think the general idea of pattern recognition/problem solving that is similar to the coding question would create a cool sort of puzzle, but then that would be a totally different type of analysis of the problem if you don't include the ruleset that programming provides. You would basically have to teach someone all the basics of programming to see if they understand how to fit a problem into the constraints that programming provides.

    • @WoWkiddymage
      @WoWkiddymage Před 2 lety +2

      Also, I'm not saying it wouldn't be a good idea. I think it would be really cool to tickle people's brains on the subject. I just think that the implementation of this kind of "social experiment" would be quite difficult, it would cost a lot of effort on the participants not previously understanding the limitations. Who knows though, there might be some cool ways to implement this idea...

  • @GraphicalBoss
    @GraphicalBoss Před 2 lety +93

    This coding videos are awesome! I don't get impressed by much but this is very fun and interesting. Love it. Can't wait to see the next one of this.

  • @aliahmed-vd2nt
    @aliahmed-vd2nt Před rokem +4

    for reversing a string simply use slicing
    string="Ali"
    print(string[::-1])

    • @lia_64
      @lia_64 Před rokem

      That's what i was thinking

  • @foolwise4703
    @foolwise4703 Před 2 lety +1

    Reverse string:
    lambda str: str[::-1]
    2d array sum:
    lambda arr: np.sum(np.array(arr))

  • @MUHAMMADIBRAHIM-gd1xp
    @MUHAMMADIBRAHIM-gd1xp Před 2 lety +71

    That's quite interesting, first of it kind that i have seen.... But you or the person solving it should always walk through the code so that we will learn too

    • @quanganhbui9503
      @quanganhbui9503 Před 2 lety

      Yesn’t

    • @ferociousfeind8538
      @ferociousfeind8538 Před 2 lety +1

      It's always important to make sure the answerer knows how it works, or at least gives an answer that, if the written code doesn't quite do it, does justify the thought process, and checks out.

  • @DeepakKumar-xr3oh
    @DeepakKumar-xr3oh Před 2 lety +31

    This is something that should be encouraged more. Why would someone dislike this video is beyond my comprehension.

  • @JG-le4n
    @JG-le4n Před rokem +2

    Respect to everyone who tried and solved it

  • @DNGR369
    @DNGR369 Před 11 měsíci +1

    Thanks for creating problems to solve and saving a Street Programmer out in the wild.

  • @FrontEnded
    @FrontEnded Před 2 lety +5

    27 years old nd just started to code, i love it btw

  • @user-uo5id1dd5s
    @user-uo5id1dd5s Před 2 lety +16

    Awesome idea for a video!
    You should make it series I'm sure its gonna give you tons of views
    keep up the good work

  • @jblen
    @jblen Před rokem +1

    As a cs student who did a year in industry last year, learning programming can get you a whole lot more than $100.
    (But a little extra cash is always appreciated, especially for just a few minutes of your time!)

  • @biniteshome1403
    @biniteshome1403 Před rokem +1

    i like the dude who added error handling, catching errors so they don't hit the ground. epic

  • @syedayaanhussain6151
    @syedayaanhussain6151 Před 2 lety +35

    Q1-
    #reversing a string in 2 lines
    inputstr=input("Enter the string here")
    print(inputstr[::-1])

    • @halbgefressen9768
      @halbgefressen9768 Před 2 lety +15

      #imaprogrammerandneedtotelleveryone

    • @Mariiius53
      @Mariiius53 Před 2 lety

      What language is that ? I never saw " ::- " operator wow

    • @syedayaanhussain6151
      @syedayaanhussain6151 Před 2 lety

      @@Mariiius53 python and using slicing

    • @Pong-IT
      @Pong-IT Před 2 lety

      echo implode('',array_reverse(str_split($string)));

    • @Mariiius53
      @Mariiius53 Před 2 lety +3

      Real programmers make it in brainfuck

  • @teeraucher
    @teeraucher Před 2 lety +42

    its cool to see that so many people are actually getting in to coding. But still I cant stop myself thinking the whole time: "But that's a one liner?!" xD

  • @MyAmazingUsername
    @MyAmazingUsername Před 10 měsíci +15

    5:40 He has some typos and syntax errors but the overall concept is great. It makes a dict map of "which remainder maps to the current number". And as soon as it encounters that remainder as a unique number, the dict returns the complementary number that sums with it. Good job coming up with that on the spot.

    • @TUMATATAN
      @TUMATATAN Před 10 měsíci +3

      Honestly, he overcomplicated that. He had the right idea but then went rogue with the syntax and that code is definitely not maintainable. lol

  • @wenreloz
    @wenreloz Před rokem

    Find the numbers in the array that sums up a given number? You can pick two random numbers in the array inside a while loop.

  • @dj_b1627
    @dj_b1627 Před 2 lety +25

    That was insanely entertaining and funny. Please do this again.

  • @cringe2474
    @cringe2474 Před 2 lety +6

    Cool! Make more of these type of videos!

  • @sirwee_
    @sirwee_ Před rokem +1

    The 2sum guy is my hero, the man hand writes error handling into it for no reason ❤️

  • @johnshaw6702
    @johnshaw6702 Před rokem +1

    In most modern languages, the simplest answer is the same. You could write it in C and you've already covered C++, C#, and others. There my be some difference in syntax, but the algorithm is the same.

  • @supriyosarkar5132
    @supriyosarkar5132 Před 2 lety +272

    To the first girl, who solved the reverse string problem : Nick just forbade you to use inbuilt functions, not inbuilt operators.
    Simply - string[::-1]

    • @googleuser4203
      @googleuser4203 Před 2 lety +47

      It is more of a solving the problem mathematically with basic tools rather than how much do you know about the language itself.

    • @manankumar3983
      @manankumar3983 Před 2 lety +3

      op bro . i also thought the same

    • @carsnnn5018
      @carsnnn5018 Před 2 lety +3

      Literally posted a comment about that before seeing this one lol

    • @cgme7076
      @cgme7076 Před 2 lety +2

      I immediately yelled “LIST COMPREHENSION”

    • @droidgenetx
      @droidgenetx Před 2 lety +3

      noice.

  • @Rocco7070
    @Rocco7070 Před 2 lety +5

    awesome video, I want more programming on the street

  • @coreyellis3327
    @coreyellis3327 Před rokem +46

    One day I’ll be a coder and work at a big data company and reply to this video that I made it! Thanks for all this information time to get started on my journey! 💪

    • @minoroyale1226
      @minoroyale1226 Před rokem +6

      You can do it it's not so hard.
      I watched this videos months ago before starting to learn and now they are so easy even though i wasn't dedicated to it like i would not code for two whole week .

    • @Thiago--de6ez
      @Thiago--de6ez Před rokem +1

      @@minoroyale1226 fr, to me i'm learning things really quick, might be because i have great willingness to learn.

    • @TheLemonyOne
      @TheLemonyOne Před rokem +1

      how goes the journey fellow dev?

    • @Zeeshan_Tanwri
      @Zeeshan_Tanwri Před rokem +1

      How is your journey going

    • @coreyellis3327
      @coreyellis3327 Před rokem

      @@Zeeshan_Tanwri ChatGPT has made me somewhat an expert. Thank you for checking in. Hope everyone's coding journey is going well :))

  • @anthonythompson3806
    @anthonythompson3806 Před 2 lety

    Passing in an array of sub arrays use arr.flat(Infinity) and then run that through a for loop -- JS.

  • @MrNsaysHi
    @MrNsaysHi Před 2 lety +27

    competitive programmers:
    “are you insulating our traditions?”

  • @anvithkakkera7196
    @anvithkakkera7196 Před 2 lety +9

    wow, u went from 30k to almost 80k subs! amazing, didn't realize how much ur channel grew recently

  • @Random-ey7tq
    @Random-ey7tq Před 2 lety +4

    THE GOLDEN RULE of coding; if you stuck in a question, just throw a hashmap to it. 90% of the time you'll make at least some progress...

  • @thebicycleman8062
    @thebicycleman8062 Před 8 měsíci

    That TWO SUM problem - gosh i finally learnt how to solve it after THREEEE weeks from not knowing a single thing about coding - every single WORD of code felt like being hit by 1000 new bricks, it was probably the hardest thing to ever wrap my head around n now when i think about it - its SUPER logical and optimized
    - I remember the most concept i codnt fathom was how is a hash map able to sore a key and be able to retrieve it instantly.. that concept I just couldnt wrap my head around. Like how can a hashmap be able to INSTANTLY point to its location in the memory or whatever magical place keys get stored at.. fuk now that i am typin this i am not even sure i fully know!

  • @K_CO_GurvinderSingh
    @K_CO_GurvinderSingh Před 2 lety +9

    hard part is the complexity or constraints on input data . Thats what makes u apply mathematics

  • @Shay001
    @Shay001 Před rokem

    “when will we need this in life” This. This is when you need it.

  • @alejandromichelena66
    @alejandromichelena66 Před rokem +1

    if youre interested in a better way for the reversed string (in python):
    def reverse(st):
    result = ''
    for index in range(len(st)):
    result += st[-(index + 1)]
    return result
    all you do is use the regressive index (iterable_variable[-value]) in python to sum each respective character in a loop.

    • @LambdaSan
      @LambdaSan Před rokem +2

      or even better str = str[::-1]

    • @solaire_of_the_east
      @solaire_of_the_east Před 11 měsíci +1

      @LambdaSan Bruh, that's what I was thinking. All these people defining function for a simple task.

  • @jonathangigi3163
    @jonathangigi3163 Před 2 lety +4

    if only the questions in the test were this simple

  • @mugu007
    @mugu007 Před 2 lety +3

    3:37 that man just bluffed his way across with C+ as a language and still got that cash.

  • @dizzyaaron
    @dizzyaaron Před 2 lety

    Kenny where have you been my brotha!? Cant belive I am JUST finding out about your channel! Haha! Keep up the videos brotha! Great production quality!

  • @hanac5586
    @hanac5586 Před rokem

    The editing is great!

  • @bubble418
    @bubble418 Před 2 lety +3

    bro with the indian accent said i haven’t done this in a while but pulled out the optimal solution😭😭😭😭😭😭😭

  • @PinoyDiskubreChannel
    @PinoyDiskubreChannel Před 2 lety +82

    I thought the First guy - Indian guy would solve the Difficult round first...but SAVE by the SECOND Indian guy! WAY TO GO INDIAN TEACHERS on CZcams!!!!

    • @NoOne-sy5fg
      @NoOne-sy5fg Před 2 lety +1

      The hashmap guy was making things complex for himself...when it could be solved so simple in O(N) time complexity

    • @ivicamajmunskikreten9714
      @ivicamajmunskikreten9714 Před 2 lety

      @@NoOne-sy5fg lol idd, I facepalmed when I heard hashmap.

    • @MattMcConaha
      @MattMcConaha Před 2 lety +1

      @@NoOne-sy5fg I think with a hashmap the problem can be solved in O(N) even if the array isn't sorted. If the array is sorted then you can get O(N) using a more basic method, but I don't think the problem statement specified that the array was necessarily sorted. The hashmap is definitely more complicated in terms of basic operations that would need to be understood, but in code it is all abstracted away and then using the hashmap will end up with cleaner code than the other method that has the same time complexity but only works on a more constrained problem.

  • @Ounisimo
    @Ounisimo Před 11 měsíci

    The guy that solve the second problem was so confident, he sould start a youtube channel

  • @migueljunqueira287
    @migueljunqueira287 Před rokem

    In JS to last one:
    function twoSum(array, sum){
    const args = []
    for(let i = 0; i < array.length; i++){
    array.forEach(e=>{
    if(sum == e + array[i])
    args.push([e, array[i]])
    })
    }
    return args
    }
    That function return each possibly combination of two number in array that sum the "sum" variable

    • @asiamies9153
      @asiamies9153 Před 8 měsíci

      this is called the naive approach

  • @jw1ck
    @jw1ck Před 2 lety +7

    Bro the one kid that goes, “EY” when he says Java doesn’t count 😂

  • @Skatinima
    @Skatinima Před 2 lety +31

    I would never thought of using a hashmap and exceptions to solve the last one.
    All that was needed was two pointers, one starting in the beginning and the other at the end, keep checking the sum and move the appropriate pointer if the sum if bigger or smaller than the target.

    • @user-fd8nj6tx8f
      @user-fd8nj6tx8f Před 2 lety +15

      it can be done only on sorted array so complexity is O(nlogn). Using hashmap u have O(n) but also same memory complexity

    • @flavorlessquark8614
      @flavorlessquark8614 Před 2 lety +3

      @@user-fd8nj6tx8f I think the leetcode one times you out if you use the naive approach, if he the guy in the video had done it on leetcode he probably remembers doing it that way because that's a way that will get your answer validated

    • @Vikas_Kumar_Singh
      @Vikas_Kumar_Singh Před 2 lety +2

      @@flavorlessquark8614 yep and since its the first code on leetcode I think the average coders might have already solved it since when they teach DSA in courses they try combination sum as the first question to solve usually

    • @flavorlessquark8614
      @flavorlessquark8614 Před 2 lety

      @@Vikas_Kumar_Singh I would like to think that most coders, as mysef, are self thaught. It's also a thing to solve it, as it is another to solve it efficiently

    • @ferociousfeind8538
      @ferociousfeind8538 Před 2 lety

      The array is sorted?

  • @abdelhakimlamnaouar9527
    @abdelhakimlamnaouar9527 Před 5 měsíci

    In the last problem, he can just sort the array and use two pointers one at the beginning and one at the end if the sum of these two values is greater than the target sum endpointer-- else if it's less than the target sum, beginningpointer++ else return the two values

  • @nicreven
    @nicreven Před rokem

    The funny thing about C is that the "sum of a matrix" problem can just be done like
    for(int i = 0; i < length; i++)
    sum += matrix[i];
    since matrices are almost the exact same as 1d arrays

    • @bultvidxxxix9973
      @bultvidxxxix9973 Před 11 měsíci

      That depends on how the matrix was created. If the matrix is a jagged array you'll just sum up the pointers with that code.

  • @digitalmoustache8416
    @digitalmoustache8416 Před 2 lety +16

    Sponsored by Skillshare, Udemy getting all the PROMOTION is just hilarious. Thanks Skillshare LOL 😂

  • @aryelpanda
    @aryelpanda Před 2 lety +4

    you should zoom even for a second on the code, each time so we can have a look at it.

  • @artemych856
    @artemych856 Před rokem +1

    I'm 18 and I've been studying programming for 1 year at the university without any practice and I solved those problems easily)

  • @ericjorgearnezinochea9679

    All of them were pretty easy. Thank you. I still have some imposter syndrome and this helped.

    • @yoshiontheloose
      @yoshiontheloose Před 2 lety +1

      When you have imposter syndrome, think of the robot guy from Grandma's Boy and laugh about that character lol. You're doing great, keep it up and code everyday.

    • @datcate9116
      @datcate9116 Před 2 lety

      This is my week 4 of CS and I'm alr stressing that I don't understand any of these lol

    • @billr5842
      @billr5842 Před 2 lety

      @@datcate9116 I am in my first hour of CS and I dont understand any of this

    • @datcate9116
      @datcate9116 Před 2 lety

      @@billr5842 I'm no longer in CS HAHA

  • @Fuze_Youtube
    @Fuze_Youtube Před 2 lety +3

    I live in Chicago, I'm currently enrolled in college, going for my bachelor's in game design. I can't wait to be able to do this.

  • @charlesreed8420
    @charlesreed8420 Před 9 měsíci

    for the reverse string one, id just put "return inputStr[::-1]"

  • @GUESSMM
    @GUESSMM Před 2 měsíci +1

    Exacto, son los mejores, esperemos sigan siendolo.

  • @kennygunderman
    @kennygunderman  Před 2 lety +21

    Make sure to check out Nick's video for part 2! czcams.com/video/WDuZ_S_9vLg/video.html

  • @Kabeer2004
    @Kabeer2004 Před 2 lety +8

    the way i thought of doing the twosum question after you explained it was to have two for loops (like a nested loop)
    so the outer loop will pick one number at a time from the array
    and then with the inner one you check the sum with every other element except itself to see if you can get the sum
    and if sumarray==sum then you can easily print the numbers because you already have their indexes from the for loop
    can be implemented in any popular language of course
    taking the sum and subtracting each element and then checking for the difference in the array was an interesting approach to me
    very cool video :) subbed

    • @DogeMultiverse
      @DogeMultiverse Před 2 lety +1

      in this case, the array is sorted. so you don't actually need to double loop through every element in the array. as long as the sum is bigger than the target sum, you can skip the 2nd level loop

    • @Kabeer2004
      @Kabeer2004 Před 2 lety

      @@DogeMultiverse you're right
      didnt think of that

    • @ferociousfeind8538
      @ferociousfeind8538 Před 2 lety +1

      @@DogeMultiverse is there a guarantee that any given array will be sorted...?

    • @amatera2
      @amatera2 Před rokem +3

      So the thing is, the solution you thought of definitely works, and it's even the first solution most people would think of. But the problem with it is that it doesn't scale well. If you have an array with a million elements, then you'll need to do a million comparisons and that's just for the first element. On the second one you will do a million - 1 comparisons and so on and so forth. It's perfectly acceptable with a small input but when the array becomes very large running it this way becomes very time consuming, as opposed to the hash map method where you only need to do, at most, a million operations in this example since you only iterate over the array once.
      This is an entire topic called "Time Complexity" and it's quite important to keep in mind if your use case requires super efficient code.

  • @thestranger8352
    @thestranger8352 Před rokem +1

    solved all the questions with simple solutions feeling confident for some weird reasons becoz i am second year it student

  • @memorializers
    @memorializers Před rokem +11

    You can optimize the very first code by just doing this in python:
    *string = str(input("Input Your String: "))*
    *print(string[::-1])*

    • @matheustran8009
      @matheustran8009 Před 9 měsíci

      return input(“your string: “)[::-1]
      input() already returns a string, no need to turn it into a string again

  • @viepng
    @viepng Před rokem +3

    Remember y'all, of you ever get stuck on an interview question, throw a hash map at it

  • @gladiusrt8542
    @gladiusrt8542 Před 2 lety

    I just found this, its amazing I love your content

  • @alainirebegashumba4862
    @alainirebegashumba4862 Před 9 měsíci

    This is great I like. This inspired me to continue with my passions.

  • @ahmad.ramadan
    @ahmad.ramadan Před 2 lety +4

    0:25 only programmers would notice the ==

  • @kyuss789
    @kyuss789 Před 2 lety +241

    Super interesting watching people solve this stuff. Every question I was like “oh yeah just do this” then they come up with something completely different.
    $200 dollar guy threw me right off

    • @JordanMetroidManiac
      @JordanMetroidManiac Před 2 lety +42

      He found an O(n) solution, iterating over the array exactly three times to determine a solution if any exist, when the naïve solution is O(n^2), using nested loops. I didn’t see the hashmap solution lol. He deserves the $200.

    • @quasii7
      @quasii7 Před 2 lety +3

      But he made a small mistake. In Python list object doesn't have any attribute called length, len(arr) would have been correct instead

    • @JordanMetroidManiac
      @JordanMetroidManiac Před 2 lety +32

      @@quasii7 Yeah. He had the right idea though and definitely could have debugged it given the chance.

    • @RandomVideos-yz5qf
      @RandomVideos-yz5qf Před rokem

      @@JordanMetroidManiac He had the right idea with the subtraction and then finding the other value within the remainder of the array, not sure why he overcomplicated it by using the hashmap as his first attempt. Interesting to see regardless.

    • @sidharth8007
      @sidharth8007 Před rokem +1

      @@RandomVideos-yz5qf That's a O(N^2) solution though since you need two for loops. The way he did it (storing using a dictionary), you can do it in a single loop O(N) solution.

  • @Taterzz
    @Taterzz Před rokem +2

    if there's anything i learned from my astronomy degree, it's that everything can be solved with for loops.

  • @jinks908
    @jinks908 Před rokem +1

    That smile when he said “perfect candidate” to the first girl, we all knew what he really meant lol

  • @SubashsVlogs
    @SubashsVlogs Před 2 lety +8

    Real programmers are probably sleeping in their rooms 😂

  • @crayder1100
    @crayder1100 Před 2 lety +8

    I wanna agree with that fella at the end, programming is an essential skill. People use the skills needed for programming all the time already. But learning programming languages, efficiently writing algorithms, learning how to best store information, etc, all of these surprisingly make thinking and processing information easier for me. I don't know how to explain it.
    Which brings up a good side point, I SUCK at explaining things. But thinking about things in a programming sense helps with that too.

    • @PySnek
      @PySnek Před 2 lety +6

      You also need the skill of plumbing every day to take a shit on your toilet, or the skill of an electrician, to give power to your computer. Today everyones flying, do you also need to know the basics of operating an airbus or boeing airliner? You wear clothes everyday... why don't you learn how to sew and manufacture shoes, pants, jackets? Life's short, people are into different things. Not everyone want's to learn how to code, or how hardware works.
      Most people don't even understand, how a car motor runs, or how we breath with our lungs in detail.
      Do you know, how to help a woman giving birth? This should be an essential skill in my opinion. Nothing's more essential, than the creation of a new human beeing.

    • @mariam6799
      @mariam6799 Před 6 měsíci

      ​@user-hq4cj6rw7b "Programming is an essential skill".
      "CAN YOU FLY AN AIRBUS HUHH"

    • @mariam6799
      @mariam6799 Před 6 měsíci

      ​@@PySnekDude, chill out. Programming is a more valuable work than making clothes just from the fact that its used in more than 100 careers for various stuff. If you don't like it, don't learn. But denying it's importance shows how immature you are 😂

  • @Cl0udWolf
    @Cl0udWolf Před rokem

    id love to see someone answer using matlab, most of these r 1 liners
    "doesn't matter what language"
    Matlab:
    1. string{1}(end:-1:1)
    2. sum(Arr,[],'all')
    3. (bit longer) [x = array of ints, t = target]
    for i1 = 1:numel(x)
    i2 = find(x + x(i1) == t)
    if(i2)
    break
    end
    end