Top Competitive Programmer vs. FAANG Interview Questions

Поділитися
Вставка
  • Опубліковано 21 лис 2024

КОМЕНТАРІ • 423

  • @81sohambelokar50
    @81sohambelokar50 2 роки тому +794

    generally one interview has 45 minutes of time .
    bro solved questions of all MAANG companies in 45 minutes.
    bro is a programming legend !!!!!!! orz

    • @jpppptrade
      @jpppptrade 2 роки тому +63

      also he is using c++ also its his first time of solving

    • @dkarbaev
      @dkarbaev 2 роки тому +75

      Side note: usually you don’t have 45 minutes to solve a problem, there’s introduction, explanation of how the interview goes, some little icebreaker, and then time left at the end for interviewee’s questions. All in all, you usually have only about 30-35 minutes to actually solve a problem.

    • @absence9443
      @absence9443 2 роки тому +17

      you have no idea what the meaning behind the interviews is, it's not primarily about just writing a quick solution that works...

    • @jpppptrade
      @jpppptrade 2 роки тому +18

      @@absence9443 no you have no idea , most people like them that can solve question this fast is because they have high knowledge of how the code works and will be able to explain it without a problem

    • @jpppptrade
      @jpppptrade 2 роки тому +38

      @@absence9443 people like him are the exception, company knows how good they are and will hire them because they have skills to solve hard problems in a short amount of time with high accuracy and saving time = saving money. he is one of world fastest problem solver, do you think big tech won't want him, then you a delusional.

  • @LM-ek2hb
    @LM-ek2hb 2 роки тому +453

    As an actual hiring manager for a FAANG-like (AR +$40B) corporation, you would sail through. Why? Because it's more important to watch your initial approach and how you transition into solving and coding. In most interviews we would even stop you and move on once we see that you have the 'chops' to eventually arrive at something that would work. ie; you're on the right track.
    The big plus was your attitude when analyzing the question. No real judgment, no 'snippiness' about wording, etc.. I've had candidates actually say out loud "This question is stupid", "This isn't a fair question", "I can't work on this without music", etc.. Lastly, we like it when there is a compile (or even better, runtime) error. We get to see how you react and where your troubleshooting skills take you first. For claiming that you are without interview experience, you did fantastic, IMO.

    • @TheDoomerBlox
      @TheDoomerBlox 2 роки тому +46

      "No real judgment, no 'snippiness' about wording, etc.. I've had candidates actually say out loud 'This question is stupid' "
      You could say he's here to solve problems, not look as if he's solving problems.
      What do people who want to solve problems do? Not care about how they're going to look solving the problem, that's waste of effort that could go into solving the problem.

    • @andreibida
      @andreibida 2 роки тому +15

      must be netflix 🤡

    • @nathanielme2622
      @nathanielme2622 2 роки тому +13

      hiring manager ... No real judgment, no 'snippiness' about wording, etc... did you actually give technical interviews before? The wordings are pretty bad often the people would give a right answer to a different question than the one stated.

    • @LM-ek2hb
      @LM-ek2hb 2 роки тому +17

      @@nathanielme2622 That hasn't been my experience whatsoever. Let's see.. Mon I interviewed 2 people, Tue just 1, yesterday 3 and today 2. So I give roughly 8 technical interviews per week (no interviews are scheduled on Fri). Since there is no "right" answer to the questions we ask; or incorrect answers to questions we didn't ask, I'm not sure what you mean by 'pretty bad wording'. We're always looking for very adept developers that also have excellent communication skills however.

    • @munchuwu1649
      @munchuwu1649 2 роки тому

      @@LM-ek2hb Man, you sound so full of yourself ngl.

  • @Codeaholic1
    @Codeaholic1 2 роки тому +387

    Programming is a small part of a job as a developer. You'll spend, especially as you grow in your career, vastly more time listening to others and communicating with them about the project, their design requirements, things you uncover as the project progresses, and the challenges you end up facing. The coding interview test is mainly, can you code reasonably well in a small contrived example. These are easily gamed by practicing a few core concepts that you're likely to encounter. As an interviewer I value being able to communicate what and how you're solving something far more than can you write the perfect solution. And you'll get huge bonus points if you understand the industry and the business goals driving the project.

    • @piotr780
      @piotr780 2 роки тому +11

      not true

    • @andrewferguson6901
      @andrewferguson6901 2 роки тому +49

      @@piotr780 incorrect

    • @Werebear2
      @Werebear2 2 роки тому +37

      This is true for almost any "white collar" job. Your ability to communicate and work with others is far, far more important for your long term career than technical skills. Also, sometimes teams will prefer to hire an amicable, communicative person over a slightly more technically proficient candidate.

    • @somerandomchannel382
      @somerandomchannel382 2 роки тому +8

      @trey
      this is incredible wrong information you putting out.
      Of course companies will appreciate your personal sides and qualities. But it is essential what you bring to the table as a coder that they are looking. However what Trey Dempsey trying to say is. You can "educate" a person on the fields while working. For instance - if the company hires you and you have understandable business skills. Meaning. You can be available during meetings, you understand you need to be work coherently on tasks to solve them. And don't be afraid to ask questions when you get stuck.
      But they also provide you 3-4 months of education activities to learn to code in whatever language or programming skills that you might wanna boost. The difference is learning while working is that you often learn with others, developing social connections and being a socially active person instead of sitting all time alone at a computer. Learning together means you also learn for a purpose. Using said knowledge in a real project will help you to "keep" that knowledge much more.
      Meaning you work on yourself, as well can provide quality work to the company.

    • @bobbycrosby9765
      @bobbycrosby9765 2 роки тому +15

      I wouldn't say it's a small part of the job. It's a big part of the job. But sometimes, depending upon the project, coding is the easiest part of the job, and the hardest part of the job is figuring out what should be coded in the first place.
      For example, most of the issues in our tracker start as something like "we want to add something so customers can track their orders". Or "Someone in Japan tried to add something to their cart and something went wrong". Okay, well, that's helpful.

  • @aries3690
    @aries3690 2 роки тому +640

    chad Competitive programmer vs virgin leetcoders ! Nice video, it was cool to see you second guessing yourself on such relatively easy questions cuz you dont trust yourself, Happens to the best of us! Keep up with the awesome content lately!

  • @mmdts
    @mmdts 2 роки тому +15

    I love this video. Btw, interviewers expect us to speak out our minds a lot during the interview. It gets really awkward if we think silently.

  • @nskybytskyi
    @nskybytskyi 2 роки тому +135

    Things you don't want to do in an interview from a style perspective:
    1. calling class members "global variables";
    2. creating unnecessary public members;
    3. copying heavy params around (they are passed by ref for a reason);
    4. using C-style arrays in C++ (one std::array cries every time you do);
    5. including and using namespace std (namespace pollution and slower compilation times);
    6. vector (just don't);
    7. VeryLongTypeName* = new VeryLongTypeName() (use auto instead);
    8. Not using const wherever you can.
    Overall your coding style clearly shows that you are a competitive enthusiast with not much industry experience (at least not in C++). That is generally fine for internships and entry-level positions as long as you solve the problems, but would be considered a downside for anything beyond that (at least in some companies).
    Other thoughts:
    - In q1 I would consider using dsu (not as a primary solution, but as a potential follow-up). As a data structure, it's more adaptable, in case you want to switch it to semi- or fully-dynamic connectivity later. It also reduces code duplication on the project scale that you have for dfs (unless you use visitor pattern, which I assume you are not familiar with anyway).
    - In q2 it's debatable whether you should've gone for the merge sort. What if you want to keep the original lists too? What if you don't want to, but you don't own them and your coworker (who owns them) wants to? Why are we using raw pointers in 2022 anyway? I would not select a policy on "in-place vs not in-place" without explicitly talking it through with the interviewer.
    - In q3 for even x you get that 2n is divisible by x, so you can actually do better in O(divisors), but coding it from scratch is rather painful (unless you want to resort to sieve which kind of denies the point).
    - In q4 using vector for static set/map is actually a competitive meta for squeezing extra logs in where setters don't really want you to (n sqrt log or ICPC being common scenarios).

    • @Arcvx
      @Arcvx 2 роки тому +4

      Very insightful

    • @ColinGalen
      @ColinGalen  2 роки тому +60

      Oh yeah, I totally forgot to mention the style aspect - you are totally right that I used the "cp style" since I'm not familiar with industry C++, and that's another artifact of having a lot of cp experience but nothing else.
      Thanks for the feedback - it will almost certainly prove useful later down the line when I end up in a real interview scenario.

    • @yath3681
      @yath3681 2 роки тому +6

      What is wrong with vector ?

    • @nskybytskyi
      @nskybytskyi 2 роки тому +1

      @@ColinGalen 😋 I recently found out that reading certain books helps a lot with style. Can recommend Mayers and Sutter, potentially Alezandrescu later. Some of them are pretty old but still relevant, especially since you may have missed some features that were introduced to the language when you weren't around (just like me).

    • @nskybytskyi
      @nskybytskyi 2 роки тому +8

      @@yath3681 Reddit, quora, stack overflow, and codeforces all have posts on the matter. Please look it up, as I won't do a better job at explaining it than all these communities with decades of experience anyway.

  • @hemilshah7032
    @hemilshah7032 2 роки тому +101

    I highly recommend submitting your solution 3x. The leetcode time and complexity results have been shown to give WILDLY variable results, so the most important part is just complexity which you nailed

    • @cpK054L
      @cpK054L 2 роки тому +3

      if interviewers are relying on "runtime" then you might as well play captchas if you can get "fast code" on run time.... as far as I know.. .they only care about O-notation complexity since runtime is heavily hardware dependent.
      Programming any nest for loops on an Intel 4004 in this year is just trying to slay dragons with a butterknife

    • @cpK054L
      @cpK054L 2 роки тому

      @King people put so much damn effort to make it into these tech companies, that the irony of if they just made a competing product, they'd accelerate their careers.
      The cult mindset really breaks people

    • @hil449
      @hil449 2 роки тому +2

      @@cpK054L not everyone is fitted for running a business, specially early in the career

    • @OatmealTheCrazy
      @OatmealTheCrazy 2 роки тому +2

      @@hil449 This, I have no interest in rising to the highest ranks and income possible for a field.
      I just want a decently paid position that lets me not worry terribly about finances/health and gives me space for my life

    • @vineetkaddu1214
      @vineetkaddu1214 Рік тому

      You are goddamn right! I went from 401 ms all the way to 209ms on the third submission. Gonna continue spamming with a few improvements to better my ranking XD. Hackkerank has the same issue, I went from timeout to accepted after a couple of submissions of unaltered code. These sites need to provide a Spamming option, where the system runs the code a couple 100 times and get the best timings

  • @spaceclones3115
    @spaceclones3115 2 роки тому +46

    please keep the leetcode hards incoming as much as you can. this helps a lot

  • @Snafuuu
    @Snafuuu 2 роки тому +50

    This guy looks and sounds exactly like what i'd expect a "competitive programmer" to be. No idea why this was in my recommendations but it's all chinese to me and i envy you

    • @jpppptrade
      @jpppptrade 2 роки тому

      in Asia they have tests in school almost every day. that's why solving questions is a thing for Asians and they are really good at it.

    • @moritzwagner4332
      @moritzwagner4332 2 роки тому +13

      @@jpppptrade I think he's from the US so idk what China has to do with this...

    • @xxxx-rn3yu
      @xxxx-rn3yu 2 роки тому +1

      I think it's because he said it's all Chinese

  • @GameDevNerd
    @GameDevNerd 2 роки тому +62

    I've got mad respect for people who are good at competitive programming, but it's definitely a different skill and not the same thing as being a good professional. It's possible to be both a good professional and fast competitive programmer, but most people pick one or the other to specialize in. I think the two hardest things to master are complex algorithms (including efficiency) and software architecture. That's not accounting for the low-level computer science and knowing arcane things like how to avoid L2 cache misses and optimize instructions. I focus a lot on architecture and design patterns for large, complex software and some of the low-level computer science, but I don't know tons of algorithms off the top of my head or implement them in seconds, haha. When a deep, algorithmic approach is necessary to solve a problem or there is one that applies to something I'm doing I can go read how it works and get it done ... but since that doesn't happen really frequently I've never become a fantastic student of algorithms and problems.

    • @anon3501
      @anon3501 2 роки тому +2

      @@aibutttickler @aaron carter thanks for the comment i enjoyed reading it

    • @connorsmiley2294
      @connorsmiley2294 2 роки тому +6

      Same. I'm a graphics programmer so most of my time is spent implementing theory from research papers that I don't fully understand. I just know how to wrangle GPUs. Frustrates me that knowing how to sort an array 100 different ways is a prerequisite to getting into a big company.

    • @GameDevNerd
      @GameDevNerd 2 роки тому +2

      @@connorsmiley2294 not always the case man, but sorting arrays of data could be important for GPU drivers, rendering APIs, etc where you don't _have_ any type of framework or runtime environment to program against and you're some writing Ring 0 or Ring 1 code that has to operate on raw memory. Think about a GPU needing sorted draw calls and batching -- you've got to handle that somewhere -- and you've also got to work out depth, culling and lots of other things where your only inputs are structs describing the length and format of the contents of physical memory. Of course it's stupid if a company asks someone to implement their own bubble sort and merge sort for a front-end web developer position lol, but in a lot of low-level programming scenarios you don't have the luxury of a rich, built-in framework, no standard libraries, no importing 3rd party libraries to help you out. Those kinds of jobs will definitely ask you some heavy computer science questions and stuff about algorithms and data structures, if it's relevant to the field and the role they're hiring for.

    • @GameDevNerd
      @GameDevNerd 2 роки тому +1

      @@connorsmiley2294 I've worked on realtime 3D engines and I'm currently working at a company doing game development with Unity, which is a lot less painful most of the time. Unity is pretty sweet compared to rolling your own engine from scratch, haha, but game dev comes with whole new sets of high and low level problems to work out and things like fluid, high quality animations often feel just as difficult as trying to bend DirectX12 to your will 😄

    • @connorsmiley2294
      @connorsmiley2294 2 роки тому

      @@GameDevNerd Yeah depends what you like. Unity is nice for indie and beginners, but for AAA Unity is a piece of junk that is kept alive by mislead investors. I come from AAA engine dev so I know the difficulties of game development very well :)

  • @pantherwolfbioz13
    @pantherwolfbioz13 2 роки тому +9

    Thanks Colin! Amazing work!!!

  • @eclypze_
    @eclypze_ 2 роки тому +14

    Truly amazing! I hope you do more of these and It would be nice if you could also post your thought process in this question and how you found the solution!

  • @isiahfriedlander5559
    @isiahfriedlander5559 2 роки тому +5

    Your hair is marvellous, oh my god…
    I feel like Patrick Bateman staring at Paul Allen card

  • @a.m.6973
    @a.m.6973 Рік тому +1

    For the second problem, all numbers are between -10^4 and +10^4. Since the range is twice K, you can just map all the numbers to the range [0, 2x10^4] and do a Counting Sort in linear time and map them back before returning the result.

  • @junveld4830
    @junveld4830 2 роки тому +2

    I'm so happy to see that even fast coders do not get their tasks, because for me looking at this was like "wtf, they just start ahead writing code when I'm still reading, they are probably geniuses", and now I can see that we're all just people

  • @tiansivive
    @tiansivive 2 роки тому +18

    Dont know why this popped up in my feed, but it's the exact kind of questions I hate to see in interviews. I hated them as a candidate and I hate them as an interviewer these days.
    It tells me nothing about an engineer's ability other than they are good at puzzles. I could just as easily hand out a bunch of sudokus instead. If you've never done sudokus you'll struggle, and it might be impossible if I give you a harder one. But if you have sudoku experience, you'll breeze past them. Either way, I gain nothing of value regarding actual software engineering.
    The typical corporate justification here is something along the lines of "But it helps interviewers see how you approach unfamiliar problems". Bullshit. I'm not hiring you for how good you are at tackling the 1% of esoteric issues you'll encounter, I want to know how well you work 99% of the time, with the normal boring stuff.
    Code style, structure, readability and problem modelling are far more important that working out a solution. If I don't understand something, I ask for help, and as a team, people can always come up with the solution. But it's up to the individual engineer to actually write functional, understandable, robust code.

    • @denizorsel1029
      @denizorsel1029 2 роки тому +2

      I am actually ok with when FAANG companies push leet code interviews to filter candidates eventhough I agree with you. I hate to see small to mid corporations following the sentiment though. Man all you need is CRUD, DevOPs and apply design for 99% of the cases and for the rest you will use a third party service nonetheless. Innovation versus application. You don't need a formula 1, or a rally driver. You need a bus / truck / taxi driver who is consistent, efficient and performant while being good in communication.

  • @henrikholmstrom7722
    @henrikholmstrom7722 2 роки тому +29

    Would love to see more indepth explainations for the solutions.

    • @lunarcdr3083
      @lunarcdr3083 2 роки тому +2

      Didn't he already said he wasn't gonna do that? Why don't you experiment with it yourself, even better.

    • @RubberTag
      @RubberTag 2 роки тому +7

      @@henrikholmstrom7722 No need to be rude about it.

    • @stevo-dx5rr
      @stevo-dx5rr 2 роки тому +4

      @@lunarcdr3083 The premise of the video was that a vet competitive coder would tackle interview-style questions, and thus it’s fair to ask for solution explanations given the fact that explaining your thought process is a majorly important part of answering interview-style questions.

  • @renatatostada3318
    @renatatostada3318 2 роки тому +3

    For the facebook one: I worked on a very similar problem to this when i was in school and I think you still got it faster than I ever would have

  • @davidalejandroramirezduena7131

    So... This is the guy my gf told me not to worry about... You're damn good bro

    • @BBWahoo
      @BBWahoo Рік тому +1

      This guy is the gf 🥵❤️

  • @golu3990
    @golu3990 2 роки тому +3

    The merge sort algorithm doesn't have the same time complexity as your solution. You are essentially using heap sort on the entire input which is \theta (n log n). The "merge sort" algorithm would actually make use of the fact that the lists are already sorted and maintain a priority queue of size at most k, so its time complexity would be \theta (n log k).
    Edited to add: I was talking about the Apple interview problem.

    • @hidude1354
      @hidude1354 2 роки тому +1

      a min-heap priority queue solution would be O(nlogk). the difference between using a min-heap priority queue and a divide and conquer algorithm occurs in space where div-conque is constant space while heap based in O(k) space

    • @golu3990
      @golu3990 2 роки тому

      @@hidude1354 I don't know which "a mean-heap priority queue solution" you mean here, but the solution implemented in the video - also using priority queue - is \theta (n log n).

    • @hidude1354
      @hidude1354 2 роки тому +1

      @@golu3990 min-heap, no such thing as a mean-heap. I agree that his solution is nlogn, but i'm saying that if you properly use a min-heap priority queue it is nlog(k) since at most your priority queue will have k elements. I'm pointing out that the difference in the merge sort/divide and conquer solution to this is in space, not time

    • @golu3990
      @golu3990 2 роки тому

      ​@@hidude1354​> i'm saying that if you properly use a min-heap priority queue it is nlog(k)
      Oh, you are merely repeating what I had already stated in my first comment.
      >I'm pointing out that the difference in the merge sort/divide and conquer solution to this is in space, not time
      What divide and conquer solution are you talking about?

    • @UNMEASURED100
      @UNMEASURED100 Рік тому

      Just take the values from the Linked Lists and store them in an array. Then sort the array and make a new Linked List from that array and return that new lIst.
      This is an easy solution to the problem but probably not very efficient.

  • @dungtrinh8595
    @dungtrinh8595 2 роки тому +3

    solving hard question under 15 mins. you would easily pass the coding interview in MAANG. Maybe the only one would give you problem is amazon cause they have Leadership Principle interview and it is a mixed bag

  • @tycox9364
    @tycox9364 2 роки тому +6

    Where is the simulation where stakeholders ask how to connect excel to Kafka?

  • @calmelbourne
    @calmelbourne 2 роки тому +19

    With the Amazon problem, the solution is also just equal to the number of odd factors of the number. So I was thinking just divide out by 2 as many times as you can, return 1 if you just have 1, or otherwise check for odd factors up to the square root, double it, and add 1 if the square root is also a factor (ie the number is square). I'm not a programmer but I do study Maths and that is what I came up with.

    • @m1ch3lr0m3r0
      @m1ch3lr0m3r0 2 роки тому +3

      Why is it equal to the number of odd factors?

    • @GenesisAkaG
      @GenesisAkaG 2 роки тому

      This seems to contradict the examples given. How would you get 4 from 15 like this?

    • @user-dh8oi2mk4f
      @user-dh8oi2mk4f 2 роки тому +7

      @@GenesisAkaG 1, 3, 5, 15 are the odd factors of 15.....

    • @calmelbourne
      @calmelbourne 2 роки тому +3

      Yes, exactly. "Odd factors" must include 1 and the number itself with the way the question is defined here.
      @Michel An easy way to see it is to think about the possible lengths of the consecutive strings, and notice they are symmetrical. They are either of odd length, so the centre is a whole number and the sum will be an odd multiple of that, or they are of even length, so the centre is halfway between two numbers but every pair will add to its double, which is an odd number.
      eg1 4,5,6,7,8 is an odd string and the centre is 6. The symmetric pairs all add to 2x6 so the total is 5x6
      eg2 4,5,6,7,8,9 is an even string and the centre is 6.5 The symmetric pairs all add to 13 so the total is 13x3
      It then takes a bit of proof to show that each odd factor can be used to make a sum in exactly one of these two ways, and the other way will lead to the string containing non-positive numbers.
      (In fact, if we allowed non-positives numbers in our strings our result would be exactly twice as big.)

    • @cobalius
      @cobalius 2 роки тому +3

      Lol i've thought the same but i'm not a math guy or anything

  • @andrewchen1744
    @andrewchen1744 2 роки тому +2

    Hey man! You are so cool, and the video is dope. BTW I like your hairstyle LOL

  • @paulh784
    @paulh784 2 роки тому +9

    Awesome video man! I hope it goes more viral for you! It was very interesting and educational.

  • @NamanCodes
    @NamanCodes 2 роки тому +5

    This motivates me to code more you are awesome brother 💯❤

  • @morshedulislamriaad6496
    @morshedulislamriaad6496 2 роки тому +6

    Wait, that algo expert guy will call you for collaboration.

  • @anime_time4037
    @anime_time4037 2 роки тому +9

    Please bring back your topic streams dude. btw nice idea

  • @ProgramadorSagaz
    @ProgramadorSagaz 2 роки тому +9

    Great content! I think a fun next step would be having a calibrated FAANG interviewer to do a mock interview with you. The biggest difference between cp and interviews is not about optimality. To be honest, you can actually clear interviews without finding the most optimal solution for every problem. A bunch of things matter on a real interview, to mention a few:
    - You need to be able to fully explain your approach before writing any code. Some interviewers will stop you when you start writing code to think, but some will just write it down as a red flag.
    - You need to create proper variable names and think more about code readability.
    - You don't absolutely need, but it helps a lot to explain your code out loud as you write it (if you don't, it looks like you just memorized things like the dx and dy vector to check all directions).
    - There is no auto-testing, and you would have to run your code manually out loud (which takes time), and it would be much harder to find the bugs on Q1
    Don't get me wrong, I'm not implying you can't do these things. It is just that if you don't, then an interview question is just an easy CP question, because often the interview questions will avoid any kind of novelty to avoid bombing people who couldn't get a "trick" or something like that. Looking forward to watch more videos from you evolving on this!

    • @hidude1354
      @hidude1354 2 роки тому

      your first point is pretty major, it's hard to really do an interview question on your own because you need someone to fully explain your solution to and they will see if it makes sense before your fingers start typing any code

    • @lucaslugao
      @lucaslugao 2 роки тому

      @@hidude1354 It is actually quite possible to do it in your own. I did it training for interviews and even if it is of course not as good as doing mock interviews the fact you need to say out loud what you are thinking forces you to organize your thoughts.

  • @TizzyT455
    @TizzyT455 2 роки тому +27

    If NileRed were a programmer

    • @emanuele277
      @emanuele277 2 роки тому

      looking for this comment

    • @joevaghn457
      @joevaghn457 Рік тому

      He really is his doppelgänger lmfao

  • @devkumar9889
    @devkumar9889 2 роки тому +1

    Two things attracted me to this video : 1st Relevance of topic , 2nd I thought there was a beautiful girl in video from thumbnail. I was like "Ek dum se jasbaat badal diye "

    • @multiply67
      @multiply67 2 роки тому +3

      strongest competitive programmer

  • @emptytextfield
    @emptytextfield 2 роки тому +12

    isn't monotonic stack better for the last question, since we can get the overall complexity down to O(n)

  • @TheRealAudioDidact
    @TheRealAudioDidact 2 роки тому +3

    The sad thing is that programmers have to go through the meat grinder of corporate interviews. I hope you can get back to pure programming as soon as possible!

  • @nomad_1997
    @nomad_1997 6 місяців тому +1

    "UGH, why is this Java?" *switches to c++*
    what a hero

  • @jsaenzMusic
    @jsaenzMusic 2 роки тому

    Naur an edraith ammen! Naur dan i ngaurhoth!

  • @Sindoku
    @Sindoku 2 роки тому +3

    Do have a video explaining all your solutions in this video?
    Edit: Never mind, I saw the follow up to this video in your profile video list, and the video is entitled “Dissecting FAANG Interview Questions”.
    Thanks, Colin Galen!
    I only understood one of these problems, so I’m a newb, yet I’m somehow still a professional programmer. I guess I’m just not very good with algorithms. That’s why I’m watching videos like this :).
    Have you considered putting a course together and selling it? You could use it as a side hustle and probably take in some decent cash flow! I’d definitely be willing to be $300 bucks for a beginner to hard level Leet code video. I don’t the language you do it matters, but I’d stick to either JavaScript, JAVA, or Python since they are extremely popular. Alternatively, you could just offer an alternative solutions for the different languages and do it in your language of choice. It would be a ton of work either way, but potentially worth it!

  • @benjaminmiller3620
    @benjaminmiller3620 2 роки тому +6

    Is Q1 a trick question? The specifications don't actually require the program to make a large island, merely to [optionally] make a single node change, and then return the size of the biggest island. The simplest solution would be to make no (or a random) change, and run a graph segmentation. Or is this question just REALLY badly written? E.g : "Example 1, Output: 1, Explanation: change one 1 to a zero, leaving exactly one island of size 1." This fulfills the requirements as written. If this is not what they actually want, who-ever wrote the question fails at writing good product specifications.
    Should the requirements be: "return the size of the largest island _possible_ in grid after applying this operation."?

    • @rosly_yt
      @rosly_yt 2 роки тому +1

      I was also confused by this question.

    • @Hellhound_RedFox
      @Hellhound_RedFox 2 роки тому

      "You are allowed to changed at most one 0 to be 1" means you cannot change a 1 to a 0.

    • @benjaminmiller3620
      @benjaminmiller3620 2 роки тому

      @@Hellhound_RedFox True. Example still works if you make no changes though.

  • @kormkor6390
    @kormkor6390 2 роки тому +11

    Can someone explain to my simple mind the rationale of the Amazon solution, namely the logic according to which ans is incremented and why is it correct?

    • @iam_a_sad_khan
      @iam_a_sad_khan 2 роки тому +8

      first observation: if there is a sequence of L consecutive numbers that adds up to N then it is also unique, i.e. no other consecutive sequence of length L will add up to N. This is an obvious observation.
      from the first observation, we can say that you only need to find all the different lengths (Ls) for which there is a possible sequence that adds up to N.
      so you can try from L = 1 to L = N, and if for some L we can say that there is a sequence that will add up to N then we increment our answer by 1.
      second observation: L doesn't need to go up to N. L only needs to go up to X such that (X * (X + 1))/2 12 ...
      so if (N-v) is a multiple of x then we can say there is some sequence of length x that adds up to N.
      There are other more clean solutions to this problem too.

    • @Daniel-ih4zh
      @Daniel-ih4zh 2 роки тому

      @@iam_a_sad_khan for the last part, i think you also say for starting number x, sum of next k numbers to equal N is N= x + x +1 + x+2 ... x+k = x(k+1) + (k-1)k/2. If you plug in an x you get a quadratic and i guess you just have to check if the root is real and positive, which takes like 2 comparisons.

  • @alexanderlachmann7292
    @alexanderlachmann7292 2 роки тому +1

    I think you also want to talk about the thought process.

  • @user-zu1ix3yq2w
    @user-zu1ix3yq2w 2 роки тому +1

    Those competitive programming sites kind of act like test prep for interviews. So that part is helpful..

  • @Sam-kj9ui
    @Sam-kj9ui 2 роки тому +5

    Codewizard but uses a microwave as a webcam.

  • @Stefan-vz7op
    @Stefan-vz7op 2 роки тому

    I don't get why people are writing about how being a comp programmer is very different from real software development.
    This video is about interview questions. I only watched the first question, but we learned how to do this in the first year of college. So I do not understand why people think that he is doing magic here or feel the need to distinguish this from their "real" programming.
    The first question is legit a dfs, which every programmer should be comfortable with

  • @RatherBeCancelledThanHandled
    @RatherBeCancelledThanHandled 2 роки тому

    Impressive , very satisfying to watch.

  • @iSeeSharp2
    @iSeeSharp2 2 роки тому +1

    I had plenty of interview that asked me to grab a pencil and paper and write a code there and then complained that it would not compile because i forgot semicolon.

  • @nomemeshere253
    @nomemeshere253 2 роки тому

    The constant ctrl-s is so relatable...

  • @spoopyscaryskelebones3846
    @spoopyscaryskelebones3846 2 роки тому +1

    Nice hair type brotherman

  • @kered13
    @kered13 2 роки тому +2

    24:45: I don't understand how a mergesort solution is going to be better. The naive mergesort solution would just be to dump all the linked lists into an array and mergesort that, but that's O(n*log n) and still takes O(n), strictly worse than using a priority queue merge. The slightly better option is to append all the linked lists together and merge those together, which can be done in place, but is still O(n*log n), which is worse than the O(n*log k) solution. The only other idea I can think of that uses mergesort is to mergesort the heads of the k lists to find the smallest one, and repeat that n times, but that is O(nk*log k) and O(k) memory, so still strictly worse than the O(n*log k) solution.

    • @lickit77
      @lickit77 2 роки тому +1

      I think your idea is correct but the complexities are wrong. First off if you have K lists each with N elements and just append and sort them the complexity would be O(nk*log(nk)) - ie sorting an array with size nk. The optimal solution is to use both merge sort (exploiting that the lists are sorted) and a min-heap (keeping only the heads of the lists and selecting the smallest one at each step). Then the heap contains at most K elements making the overall complexity O(nk*log(k)) which is better but really depends on your use case. If you have only 2 lists (k = 2, the classic merge sort) then it doesn't really matter either way. Hope this clears it out.

    • @kered13
      @kered13 2 роки тому

      @@lickit77 n is the total number of elements in ALL lists. That is the standard definition of n in problems like this. The solution you have described is just the solution that the video implemented, a priority queue of k elements. This is O(n*log k) and takes O(k) memory. Also there is no mergesort in this solution, only a merge. Colin Galen claimed that there was a solution that was O(n*log k) and used O(1) memory that used mergesort, but I don't see it.

    • @lickit77
      @lickit77 2 роки тому

      @@kered13 I see what you mean. Just read up how the implementation for merge sort works. It turns out you first split up the lists into 1-element lists (so a total of n lists with 1 element). Then you merge them in pairs - so at each step we merge only two lists at a time. Not sure how we compute the overall complexity but it should be O(n*logn) regardless of what k is. This makes sense because merge sort is indeed a sorting algorithm and it doesn't assume any ordering of the elements but in the problem statement you get sorted lists so we can do better with the other solution. So yes - merge sort will be worse in this problem.

  • @wsniper-dark154
    @wsniper-dark154 2 роки тому +11

    Its a really great idea to start making some interview related content. The amount of people that are interested in cp are far less as compared to interview. I wish you success and fortune. Following you from a year, best cp utuber (after william lin ( he is insane ) xD).

  • @kooltyme
    @kooltyme 2 роки тому +1

    q1 O(n^2 - area of all islands) is pos, you only need to find the perimeters of the islands to calculate the area, and then just find the best grid of a perimeter whose islands shared have the max sum area
    q2 u could just O(n > 10^4 ? n : 10^4) da shi by doing counting sort

    • @awillingham
      @awillingham 2 роки тому

      You can do it in O(n) I believe. Iterate through and find islands like he did, and while you’re scanning if you find 0s that have at least 2 adjacent 1s save them to check later. After finding all islands, iterate through possible connectors and test the combined area. It’s the same solution as his (I think) but slight optimization on the test part because you don’t iterate over every element, just potential connections.

    • @kooltyme
      @kooltyme 2 роки тому

      @@awillingham you realize finding all the islands is O(n^2) since the array is n x n

    • @YeetYeetYe
      @YeetYeetYe 2 роки тому

      @@kooltyme It's O(n*m), not O(n^2)

    • @hidude1354
      @hidude1354 2 роки тому

      @@YeetYeetYe huh where is this m coming from? iterating through and finding all islands is n * n so O(n^2). the input is an n * n grid not a m * n rectangle

    • @YeetYeetYe
      @YeetYeetYe 2 роки тому

      @@hidude1354 It's just convention really. O(m*n) is a tighter upper bound than O(n^2). You're not receiving "n" as an input length, so saying that the answer is upper bounded by quadratic time can be misleading, though it is technically correct.

  • @aksjd2768
    @aksjd2768 Рік тому

    this is great... want to do things like you... good video, keep it up!

  • @chillappreciator885
    @chillappreciator885 2 роки тому +3

    But tbh it was easy for you) I guess competitive programmers best suit for coding interviews. It's harder for guys who can actually build stuff that works but during interview they are forced to solve isolated tasks about numbers using bare arrays that no one really uses in every day work)

  • @sebinohoo2979
    @sebinohoo2979 2 роки тому +3

    You'd smash the interview process (coming from a new post-grad who's just secured a job).
    I'm not coming from a FAANG perspective, I work for a big-data company. Securing the bigger roles is 90% coding skill and 10% people skills. And you've got both.

  • @wesleyso0
    @wesleyso0 2 роки тому +3

    Awesome video, Colin! (YOOO FIRST COMMENT?!?!)

  • @warriordx5520
    @warriordx5520 2 роки тому

    All of that in 3 years? ZAMN!

  • @unibrow9384
    @unibrow9384 2 роки тому +5

    Please make topic streams for med-hard graph and dp problems

  • @encapsulatio
    @encapsulatio 2 роки тому +22

    Can you ask please your followers if they know a book or multiple books that are considered gold standard for learning all the logic necessary in type theory that is used in different papers on gradual types, dependent types?
    Thank you

    • @warriordx5520
      @warriordx5520 2 роки тому +1

      Bruh

    • @encapsulatio
      @encapsulatio 2 роки тому +1

      @@warriordx5520 Yes Bruh...what's the problem?

    • @warriordx5520
      @warriordx5520 2 роки тому

      @@encapsulatio Ask reddit? Bruh

    • @encapsulatio
      @encapsulatio 2 роки тому

      @@warriordx5520 Don't be rude ...bruh. No one asked you to speak on the Colin's behalf. Offer an answer relevant to the question or STFU.

    • @ikspb
      @ikspb 2 роки тому

      Cormen is a classic

  • @trickbaggames6579
    @trickbaggames6579 2 роки тому +1

    You didn't call delete on the ListNode* that you created on the second test. You did amazing though.

  • @Arcvx
    @Arcvx 2 роки тому +1

    Should make more of these lol. The views seem to be popping too.

  • @redrodlrowon
    @redrodlrowon 2 роки тому

    Good stuff. Thanks for making this.

  • @pinkgum
    @pinkgum 2 роки тому

    your hair is so so pretty

  • @stickyfox
    @stickyfox 2 роки тому +19

    Do you think you'd be happy working in a coding environment like that? Do you think the problems you'd be solving would be worthwhile?

    • @jpppptrade
      @jpppptrade 2 роки тому +13

      you are talking about money here most people join big tech mostly for money and experience, When you join big tech the first thing you think of is not about solving hard problems lol. Is mostly communicating with the team

    • @happywhale1786
      @happywhale1786 2 роки тому

      man, labor for living is as important or more so as labor for happiness

    • @happywhale1786
      @happywhale1786 2 роки тому +1

      @@jpppptrade Couldn't agree more, I remember the first meaningful task: I wasted 2 weeks asking for interfaces and coded for 12 hours till 4:30 am before deadline.

    • @stickyfox
      @stickyfox 2 роки тому

      @@jpppptrade well I am assuming the pay is fantastic and mainly am talking about happiness and personal satisfaction.

    • @grimfang4
      @grimfang4 2 роки тому

      The problems to solve in the work environment are very different from these. You work on things you are interested in and feel have an impact or else both you and the company got a bad deal.

  • @lostmeme9862
    @lostmeme9862 2 роки тому

    This is the new standard to get into a dev position, unless of course you know people that can get you in. In that case you don't even need to know how to code.

  • @eitkoml
    @eitkoml 2 роки тому +6

    Great programming skills combined with insufficient interviewing and work politics skills leads to severe underemployment.

  • @blake4197
    @blake4197 2 роки тому

    Do workthroughs of the Jane Street Monthly Puzzles!

  • @TrooperJet
    @TrooperJet 2 роки тому +2

    Hello idk if a legend like yourself would answer to a noob like me but would any Backtracking Algorithm be a good choice in the first task with the Island and do you often use any known algorithm or data structure or you have zero knowledge but invent everything by yourself in seconds or you have the knowledge but it isn't always the best choice so you invent everything in seconds?

    • @lovely4219
      @lovely4219 2 роки тому +4

      To answer just one of your questions: He doesn't invent a new solution every time, rather he has solved many Similar problems before and only needs to alter small details to make that previous solution work for this new problem. When a new bigger problem presents itself, you break it down into it's many parts, and for each of these parts you will either know a similar enough solution that you can tweak slightly or you will have to come up with something new. It's a mix of remembering what you solved before and creating new solutions.
      I have the tiniest bit of coding experience but this is how logical problems are solved in general.

    • @mlgpro2241
      @mlgpro2241 2 роки тому +1

      "do you often use any known algorithm or data structure"
      he uses vector within like the first 6 minutes into the video, which is a very basic data structure. otherwise, @lovely replied with how he breaks down problems
      "or you have zero knowledge but invent everything by yourself in seconds"
      no
      "you have the knowledge but it isn't always the best choice so you invent everything in seconds"
      also no

    • @TrooperJet
      @TrooperJet 2 роки тому

      @@mlgpro2241 well okay then but does he even know about Backtracking Algorithm or not? I mean it's a thing you could invent on the fly without knowing about it. I didn't mean such things like a vector, come on...

    • @mlgpro2241
      @mlgpro2241 2 роки тому +1

      @@TrooperJetI mean we can assume that he's encountered problems where that is an optimal solution, so it probably makes sense that he's used it before.
      "do you often use any known algorithm or data structure"
      I only answered your question, so dispense with the "come on"

  • @johnny2598
    @johnny2598 2 роки тому

    Average coding tutorial enjoyer vs Chad competitive coder

  • @Tenchi707
    @Tenchi707 2 роки тому +1

    You're the real coding beauty!

  • @rogerdinhelm4671
    @rogerdinhelm4671 2 роки тому +6

    These are basically automated pre-screening tasks for large companies, they are usually not considered an interview and have little resemblence of it.

    • @travbrack
      @travbrack 2 роки тому +7

      In my experience, phone screen questions are usually considerably easier than this, and on-sites are usually around leetcode medium level. Hards are pretty rare, and if you get one they'll usually give you the full 45 minutes for one question. This is for SRE but most software engineers I know have had similar experiences.
      You're getting harder questions than these in interviews??

    • @rogerdinhelm4671
      @rogerdinhelm4671 2 роки тому +3

      @@travbrack Actually no. Phone screen is easier for sure, they are basically checking that you are not insane and can speak english relatively good.
      But a lot of companies, especially popular ones, send these even before phone screen, because that way you can process people at way bigger scale than phone interviews, which are limited by suitable times and so on. So they are kind of pre-pre-screening.
      And in actual interviews, at least for me, there were a lot of architectural level questions, I guess because they don't calculate fibonacci sequences on a daily basis.

    • @zzzyyyxxx
      @zzzyyyxxx 2 роки тому +2

      @@rogerdinhelm4671 You must be more senior then, where they'd ask system design questions more than algorithmic. For juniors and even mid levels, they absolutely do ask Leetcode type questions in the interview, as well as in the pre-screen and in the phone screen.

    • @rogerdinhelm4671
      @rogerdinhelm4671 2 роки тому +3

      @@zzzyyyxxx Leetcode in phone screen? That is insane, never happened to me. I am always asked about technologies, last projects and so on.
      But I do agree, that the less experience you have, the harder you are treated on an interview, paradoxically. I guess they know they have all the leverage on their side.
      And this is strange, I think for juniors in real production it is far more valueable to learn programming language quirks, rather than algorithms, that already implemented as libraries anyway. Hiring in software engineering is really f-d up, but it is what it is. Companies are trying to copy Google of Facebook, without even knowing why and what are they doing.

    • @allenmoody7527
      @allenmoody7527 2 роки тому

      @@rogerdinhelm4671 I am almost never asked about past technologies or projects in an interview, with 3 years of experience. It’s always an algorithms question. After a weighted graph question sunk me in a phone screen I decided to just focus on algorithms studying over practical knowledge.

  • @GameChameleonChannel
    @GameChameleonChannel 2 роки тому +3

    @Colin Galen, I want to be as good as you are, may I ask what you do in order to continue being top .1%? I have ~10 hrs a day to study what do you suggets I focus on in order to be come the best?

  • @prathameshkaole8683
    @prathameshkaole8683 2 роки тому +2

    I just played the video to check whether this fellow is a boy or a girl.

  • @lucaslugao
    @lucaslugao 2 роки тому

    Cool video! One aspect of interviews that is greatly different from competitive programming is the fact you cannot test run your code. You need to "whiteboard" test your implementation and use clever test cases to spot the problems quickly. Of course knowing how to solve the question is like 80% of the work but communication, testing and overall organization is really important too and those can get you into no hire zone if ignored.

  • @popadavid6076
    @popadavid6076 2 роки тому

    What were ur roadmap to become so good ?
    Can u do a video of this ?

  • @49nishant28
    @49nishant28 2 роки тому

    Thankyou for helping front and header

  • @GlutesEnjoyer
    @GlutesEnjoyer 2 роки тому +1

    Clicked on this video because I couldn’t tell if you were a man or a woman

  • @KDSBestGameDev
    @KDSBestGameDev 2 роки тому +14

    I find it strange that people have todo leetcode stuff and such in coding interviews. I even worked for Microsoft as a Field Engineer (comparable to an IT Consultant). I never had to do any of those leetcode thingys. I do them for fun here and then and one company (small one) asked me to give them example code and another one made me test work for a day. Apart from that, I guess they just fire you when you suck :p.

  • @mohdsaaduddin3118
    @mohdsaaduddin3118 2 роки тому +1

    Good for coding interviews

  • @lewiseverett
    @lewiseverett 2 роки тому

    Love your vids man

  • @craig4android
    @craig4android 2 роки тому

    #3 I have no maths background so I would just iterate through all possible solutions, but hey at least I would stop when x (x being the start) is bigger than n/2 so it is at least optimised a little bit. Am I hired?

  • @MuhammadFaisal-wt4hn
    @MuhammadFaisal-wt4hn 2 роки тому +3

    I have no idea what I'm watching

  • @c0mpuipf
    @c0mpuipf 2 роки тому

    is writing low-level code that that mutates anything and everything - and notusing the STL - mandatory for these things?

  • @Maleficarios
    @Maleficarios 2 роки тому +3

    It is really amazing you can do this, but, without "communicating your solution" you are not really doing what you set out to do in this video.... you said it yourself interviewing requires you to explain your solutions and do it efficiently and all that.... You are just doing the same thing you would be doing for CP

  • @movax20h
    @movax20h 2 роки тому +2

    The first problem can be implemented quite easily and super efficiently O(n^2 * log*(n)) using disjoint-set data structure. DFS will be slower, O(n^4) worst case.

    • @ProgramadorSagaz
      @ProgramadorSagaz 2 роки тому +9

      He didn't just do the naive DFS solution... his solution visits each cell exactly once, hence O(N^2) complexity which is the optimal one.

    • @movax20h
      @movax20h 2 роки тому +1

      @@ProgramadorSagaz yes. I see now. Pretty good too. But I think disjoint set aka union-find is also nice solution.

    • @kered13
      @kered13 2 роки тому

      @@movax20h That's what I thought of at first as well, and to be fair log*(n) is pretty damn close to constant, so it's not really much worse.

  • @ritorujon
    @ritorujon 2 роки тому +2

    For the 1st one (Making a Large Island) you would be better off with line scanning (since it's connected only in 4 directions) instead of recursive growth of the components from each point.

  • @RayZde
    @RayZde 2 роки тому

    thank god i own my own software company. going back to corp america would be detrimental to my mental health.

  • @UuU1001.
    @UuU1001. 2 роки тому

    Are those who ace the faang interviews considered vampire slayers? It’s morbin time?

  • @Deepakmishra-kv1kb
    @Deepakmishra-kv1kb 2 роки тому +5

    can u make a sheet where a beginner should start coding for competitive programming

  • @kallaseldor7040
    @kallaseldor7040 2 роки тому +1

    I believe it is possible to solve the final problem in O(N), if you keep a stack of strictly increasing (from top to bottom) elements for odd-numbered jumps, and the opposite for even-numbered jumps.

  • @TheSnakeEyezz
    @TheSnakeEyezz 2 роки тому

    Great insight!

  • @FBerserkerF1
    @FBerserkerF1 2 роки тому

    Woah, I didn't know BrutalMoose had another channel

  • @stevo-dx5rr
    @stevo-dx5rr 2 роки тому

    Great job. Maybe next time spend five minutes explaining the solutions, since that’s a critical part of an interview.
    I’m sure you can do it.

  • @luisluiscunha
    @luisluiscunha 2 роки тому

    Apple: concatenate all the lists in one and sort?

  • @girishbhargava6367
    @girishbhargava6367 2 роки тому +3

    Man, please make a detailed video on Dynamic programming questions from code forces rated between 1000 - 1500

    • @cross4326
      @cross4326 2 роки тому +1

      You don't get much of those in this rating range.
      Try 1600-1700

    • @girishbhargava6367
      @girishbhargava6367 2 роки тому

      ​@@cross4326 Are you sure?.

  • @Markus-zb5zd
    @Markus-zb5zd 2 роки тому +1

    I like your thinking, but as you yourself know and said, not having much industry experience shows :)
    a few little comments of the things you're talking while writing the code are nice, though many of those might be redundant once you look at the code,... 5 years later someone might stumble over the code because of a problem and not having the original problem :) so some guidance into the "thinking" of the code is always helpful
    in any case for an entry level position in any language you're so massively overqualified, I wouldn't say no if you applied to our company and then sit in my classroom for me to teach you ABAP xD

  • @mitsuhide03
    @mitsuhide03 2 роки тому +1

    omg i know for competetive programming is maybe helpful but all these 2 letter variable names are unreadable. Im an engineering manager and i would be criticising that very hard.

  • @chillappreciator885
    @chillappreciator885 2 роки тому

    So on the real interview there would be a guy asking you a stupid questions and forcing you to explain what are you doing after each line of code

  • @balazstakacs4566
    @balazstakacs4566 2 роки тому +1

    5:30 "Shouldn't be java" 😂

  • @clutchedits9530
    @clutchedits9530 2 роки тому

    Please Can you make a video on how to get interest in coding

  • @aravind2624
    @aravind2624 2 роки тому +4

    In my little experience of few months in CP I never heard of Linked lists.

    • @salsichalivre5401
      @salsichalivre5401 2 роки тому

      do u have cs degree? seems you dont

    • @aravind2624
      @aravind2624 2 роки тому +4

      @@salsichalivre5401 ofc I know linked lists but didn't encounter them in any coding contests till now

    • @nayankumarbarwa4317
      @nayankumarbarwa4317 2 роки тому

      @@aravind2624 Why man

    • @khz2172
      @khz2172 2 роки тому

      @@aravind2624 cp does not have linked list questions.

  • @personalpairprogrammer7915
    @personalpairprogrammer7915 2 роки тому

    I need to step my math game up...

  • @Erliortmejurur
    @Erliortmejurur 2 роки тому

    > linked lists question
    > most talked bout interview question for some reason
    > everyone has tried to do it when they're interviewing
    > this guy fucking destroys it at 98% faster than everyone else