Google Coding Interview With A Facebook Software Engineer

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

КОМЕНТАРІ • 1,2 тис.

  • @clem
    @clem  4 роки тому +181

    So?! Is David an absolute savage at algo problems or what?! Be sure to check out the Q&A interview I did with him here: ua-cam.com/video/9ki1-xe6XzU/v-deo.html - as well as David’s UA-cam channel if you’re into competitive programming: ua-cam.com/channels/XbCohpE9IoVQUD2Ifg1d1g.html

    • @SecondThread
      @SecondThread 4 роки тому +38

      Thanks for the interesting and fun problem! I really enjoyed the opportunity to work on it!

    • @abhiramianbu5137
      @abhiramianbu5137 4 роки тому +4

      If somebody does not know this Aho-corasick algorithm, then the time complexity will be O(phoneNumberLength^2) with trie? Is there any better way to do it?

    • @same0533
      @same0533 4 роки тому +5

      why is the facebook software engineer wearing google's tee??

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

      @@same0533 That was google code jam competition tees

    • @same0533
      @same0533 4 роки тому

      @@OG_Scratch oh

  • @sumitroy2006
    @sumitroy2006 3 роки тому +3046

    23 years of software development experience. I just feel the industry is getting to such a stage that you need 2 skill sets - One skill set for doing the job and one skill set to pass interviews!

    • @jimmyadaro
      @jimmyadaro 3 роки тому +80

      Absolutely yes

    • @MaitraRoy
      @MaitraRoy 3 роки тому +217

      @@jimmyadaro I just feel if it was a more mature industry, these interview processes would be more streamlined. Doctors and lawyers do not go through loops as they have a standard professional accredition. But in this industry as it is so new, you have to prove yourself over and over again. Past experience does not seem to count even if legitimate. The problem is unlike other professions, there is no real way to verify the experience.

    • @omerahmaad
      @omerahmaad 3 роки тому +21

      Sumit you are a wise man and great comment I agree 1000% but add another thing landing on interview

    • @HangNguyen-wu3fs
      @HangNguyen-wu3fs 3 роки тому +21

      before leetcode type of questions, there were whiteboard questions. I'd rather do LC type of questions than whiteboard questions.

    • @abhi-shekb
      @abhi-shekb 3 роки тому +20

      that's true. An argument in favor of these interviews that I've heard is that big tech companies want to hire candidates who are so strong willed about joining the company that they will put in all the effort required for clearing these interviews.

  • @software_development
    @software_development 3 роки тому +1482

    dude be bussin out random algorithms that even the interviewer doesn’t know out here like “lemme use the ahoshinjinjutsu”

  • @snozzd
    @snozzd 4 роки тому +2461

    These are cool but it'd really help my ego if you hosted a mock coding interview with a candidate struggling to remember how binary search works.

    • @Dreadheadezz
      @Dreadheadezz 4 роки тому +124

      Nah deadass bro I'm right with you 😂😂😂😂😂😂😂😂😂

    • @sanchit537
      @sanchit537 4 роки тому +7

      Hahahahaha

    • @Rugg-qk4pl
      @Rugg-qk4pl 4 роки тому +129

      Actually tho seeing someone struggle a lot with an interview would be interesting but I don't think the brutal internet would be very nice about it

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

      YES that's a great idea

    • @siliev333
      @siliev333 4 роки тому +18

      Better yet a candidate that doesn't know what binary search is.

  • @KennyTalksCode
    @KennyTalksCode 4 роки тому +900

    12:45 honestly most impressed with him drawing out the trie in google docs, that's a skill in itself.

    • @kose241
      @kose241 4 роки тому +31

      The speed was insane 😂

    • @mirsella6204
      @mirsella6204 4 роки тому +48

      space bar go brrrrrr

    • @varmamahesh9725
      @varmamahesh9725 4 роки тому +27

      @@mirsella6204 I think it goes like "tuk tuk tuktuktuk tuk"

  • @xbmcme9768
    @xbmcme9768 3 роки тому +172

    For all those that watched this and feel stupid, remember David has spent 6 years coding and mentioned he used to do 40hrs a week with CP for his college years. So don't feel stupid, but do cry at the fact that it might take years to get this good.

    • @azz111full
      @azz111full 2 роки тому +28

      I've been a developer for about 8 years and this video blew my mind 😂 there are levels to this shit

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

      @@azz111full definitely agree I have 6 years of commercial experience and feel the question itself is quite ok, but the speed David types the code is absolutely insane and so it is really hard to follow.

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

      thats why it's way more chilling to watch this when you haven't even started university (Yay I don't have to know all of this already xD)

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

      what is CP?

    • @TK-fo5xl
      @TK-fo5xl 2 роки тому +3

      competitive programming

  • @kaushaldawra3527
    @kaushaldawra3527 3 роки тому +28

    that's not just a facebook engineer, that is a competitive coder

  • @tiberiusvetus9113
    @tiberiusvetus9113 4 роки тому +93

    Programming interview tip: disable spell check, auto correct, turn on mono space font

  • @somiltyagi7127
    @somiltyagi7127 4 роки тому +1000

    we can scare our interviewer by saying different algo names

    • @lolerskates876
      @lolerskates876 4 роки тому +91

      The Corbomite Maneuver Algorithm gives O( log(log(n)) time. Runs quick for even international phone numbers

    • @paraggupta2638
      @paraggupta2638 4 роки тому +25

      @@lolerskates876 ok lets go with that

    • @RoshanPradhan2
      @RoshanPradhan2 4 роки тому +4

      @@lolerskates876Can you give me a link to that algo??

    • @dev-skills
      @dev-skills 3 роки тому +20

      I found throwing out these jargons and technicals terms on interviewers face very effective in impressing the interviewer.

    • @TechnicalAnkesh
      @TechnicalAnkesh 3 роки тому

      yeah!! LOL

  • @JacobHuber
    @JacobHuber 2 роки тому +33

    I think whats good to note is not the algorithm he used specifically but the part where he took the time to consider and evaluate different solutions before implementation.

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

    The easier solution is:
    1. Reformat the strings to numbers.
    2. Create suffix tree for the main number.
    3. Check for each number if it is in the suffix tree.
    That will take O(numOfStrings*LengthOfNumber) time.
    O(numOfStrings + LengthOfNumber) space.
    This would be much easier..

    • @YASHGUPTA-cg9fh
      @YASHGUPTA-cg9fh Рік тому

      Yes that's way easier its some sought of rabin Karp

    • @GR8_Impact
      @GR8_Impact 7 місяців тому

      This problem looks similar to word break problem. Is this correct?

    • @atharvsawarkar3449
      @atharvsawarkar3449 3 місяці тому

      I solved it with a hashmap. Converted the input number to a hashmap with the count of each digit, and did the same for every test word in the list.
      then you just compare the letter counts in both hashmaps to see if the test word can be created.

  • @mariyadimitrova2097
    @mariyadimitrova2097 4 роки тому +460

    Normal people: watching horror films and yelling at the characters to get out
    Competitive programmers: watching coding interviews and yelling data structures at the interviewees

  • @renjithroy8422
    @renjithroy8422 4 роки тому +884

    Just learned to declare a variable in Javascript today and then I watched this video! 🥺

    • @KETANRAMTEKE
      @KETANRAMTEKE 4 роки тому +123

      You are on a right path young Jedi.

    • @jpncmu
      @jpncmu 4 роки тому +16

      I know how you feel.

    • @meliodas4560
      @meliodas4560 4 роки тому +75

      Don't worry, there's actually nothing particularly complex in this video. There are two primary things that you will learn with experience (assuming you pursue an education in CS or software engineering):
      1. Algorithms (and data structures), how they work, and their runtime efficiency (you'll understand deeply how nodes/trees are useful, how to code your own, and how/when to use existing libraries).
      2. How to think about problems and the structures of code you need to solve them (like building multidimensional arrays or built-in list structures, how to iterate through them, etc.).
      Once you are familiar with a language, like Java, and using different data structures, plus coding your own data structures from scratch, and learning about different ways to get lower runtime, this stuff will flow from your fingertips. Like was mentioned in the video, this is pretty much all covered at the college level in data structures / algorithms courses, which is typically around year 2.
      Cheers

    • @ancarwillis9060
      @ancarwillis9060 4 роки тому +13

      It’s a never ending process, and you got to really enjoy what you do. Formal education helps though. I completed my BS in Computer Science about a year ago and I’m sure if I had done this interview I would have just bombed it though. I took an algorithms class but frankly all I can recall from it is how to create iterative and recursive algorithms. Never even heard of Aho Corasick. Then again I work in Cyber Security and only really code for fun so my focus hasn’t been on that. Just keep at it I say.

    • @adilimanaliev3008
      @adilimanaliev3008 4 роки тому

      i swear😢

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

    I really wish in a real interview the interviewer would have allowed me to leave the hard portion of the implementation of the algorithm blank and to proceed with the rest of the bits and pieces of the program with the method signature intact 😂. You are awesome Clement! This would have made my life so much easier 😊.

  • @qutaibaal-nuaimy1697
    @qutaibaal-nuaimy1697 4 роки тому +95

    I could be wrong, but after attempting this problem it's clear that you can also solve it (pretty quickly) by converting all of the input words into numbers (using a hashmap) and then checking if those numbers are contained in the phoneNumber input with a simple if "322" in "322245" check (for example). This gives you a space complexity of O(N = Lenght of Array) and time complexity of O(N*M) where M = Length of Word. I like the uploaded solution in this video a lot, but for many new grads and underclassmen looking for jobs who feel intimidated by this, then just know there's an equally valid and much simpler solution to this problem!

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

      Thank you for this comment. Really. I was sweating and crying at this video

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

      I thought the same thing!
      I guess the "in" check is a bit slow because for it to check if first is on second, it has to go through all the second string untill it finds the coincidence (if there's one). And the method he proposed is usefull in the sense that it uses information gained with previous checks.
      For example, we have "foo" and "foots" and we want to know if either of those are on "footage", if you do the "in" check for Both, the "foo" will be very fast while the "foots" one will take (the length of the word we're searching in) minus (the length of the word "foots"), with the method he proposed, after knowing that the coincidence "foo" appears on the word, we just gotta continue from there to find out that "foot" is in the word but then the coincidence breaks. So we just took two steps by using information gained with previous comparations.
      Is like the "foreach word: If word in theThing" but where you're allowed to use information you gain with each new word, so that makes it a bit faster (and for large enough arrays, way more faster)

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

      yes.

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

      @@obsidian8037 but he had to build that aho thing which who knows what complexity its has (both time space) to populate all words. He never mentioned that.

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

      @@dionisorules it runs in linear time, just bfs

  • @Grr1967
    @Grr1967 4 роки тому +295

    Wondering if he refers to neighboring node in a graph as "bro" :-)

    • @clem
      @clem  4 роки тому +41

      🤣

    • @123aniruddhsiddh
      @123aniruddhsiddh 4 роки тому +7

      Kids and bros :D

    • @divvagg5616
      @divvagg5616 4 роки тому +1

      @@clem hello sir , can you please provide or suggest any source to learn data structures and algorithms from absolute beginner to master level .

  • @gianclaudiomoresi9650
    @gianclaudiomoresi9650 3 роки тому +13

    Basically is a normal exercise. The lenght of the phone number is in the praxis fix, so that is possible to simplify the solution. You just convert the words in number, and you build all possible permutations with these numbers. If the combination have a match with the given nbr., you find then word combination.

    • @ayushsrivastava485
      @ayushsrivastava485 6 місяців тому

      #include
      using namespace std;
      // Ques: from a numpad given a number and a vector of string of words, find all the possible words that can be formed from the number
      vector solve(string number, vector &words, unordered_map &numpad)
      {
      vector res;
      for (auto it : words)
      {
      string temp = "";
      for (int i = 0; i < it.length(); i++)
      {
      temp.append(numpad[it[i]]);
      }
      if (number.find(temp) != string ::npos)
      {
      res.push_back(it);
      }
      }
      return res;
      }
      int main()
      {
      unordered_map numpad;
      numpad['b'] = '2';
      numpad['a'] = '2';
      numpad['c'] = '2';
      numpad['d'] = '3';
      numpad['e'] = '3';
      numpad['f'] = '3';
      numpad['g'] = '4';
      numpad['h'] = '4';
      numpad['i'] = '4';
      numpad['j'] = '5';
      numpad['k'] = '5';
      numpad['l'] = '5';
      numpad['m'] = '6';
      numpad['n'] = '6';
      numpad['o'] = '6';
      numpad['p'] = '7';
      numpad['q'] = '7';
      numpad['r'] = '7';
      numpad['s'] = '7';
      numpad['t'] = '8';
      numpad['u'] = '8';
      numpad['v'] = '8';
      numpad['w'] = '9';
      numpad['x'] = '9';
      numpad['y'] = '9';
      numpad['z'] = '9';
      string number = "3662277";
      vector words = {"foo", "bar", "baz", "foobar", "emo", "cap", "car", "cat"};
      vector res = solve(number, words, numpad);
      for (auto it : res)
      {
      cout

    • @JoshSmith-sr6ks
      @JoshSmith-sr6ks 2 місяці тому

      hi

  • @weirdinternet6020
    @weirdinternet6020 4 роки тому +371

    24:03 that's me in every coding interview

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

      😂😂😂

    • @aj9706
      @aj9706 3 роки тому

      I am jobless

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

      Nice one.

    • @Fam-m4i
      @Fam-m4i 4 місяці тому

      Good one😂

  • @KaitC-j3j
    @KaitC-j3j 4 роки тому +13

    Ive GOT to see this q&a video bc i am amazed how easily he walked thru all of this.

  • @seanlau8069
    @seanlau8069 4 роки тому +50

    Now I want to see clem being interviewed XD

  • @elirannissani914
    @elirannissani914 4 роки тому +15

    You have to do a coding interview with the cherno he is SUPER SMART!!

  • @souravsaha1443
    @souravsaha1443 4 роки тому +34

    Second thread is my idol.. I follow him a lot for competitive programming

  • @andrewyemtsev4993
    @andrewyemtsev4993 4 роки тому +18

    I think that would be a good idea to giveaway an interview with ex-Googler, but with a medium level question. Would be a dope content. Since I cannot even comprehend what this mastermind is saying

  • @NickRusev
    @NickRusev 3 роки тому +13

    I just studied for loops and came across this video. My self-esteem dropped to the ground. 😅

  • @Revelatus
    @Revelatus 4 роки тому +232

    Wow I learned so much, including that I'm never gonna get a job as a programmer :D

    • @johnnycashcow1130
      @johnnycashcow1130 4 роки тому +59

      Most jobs are not this technical and algorithmic/data structure heavy. Your typical programming interview will probably not even do one of these challenges. Software engineers who have have been in development for many years probably cannot do this without a bit of training. This does not mean that the software engineer is not as good as the competitive programmer. In fact, being able to do these types of competitive programming questions does not even guarantee you to be a good developer. What's most important is your ability to understand and read code. Also, you need to understand what is being used in the industry and be familiar with frameworks. To land a job, what matters is that you understand the concepts and in the interview, what matters more than actually solving the problem, is HOW you solve the problem Break the problem down into little pieces and build upon it and don't forget to be inquisitive. Be disciplined in your studies and I am sure you'll be able to land a job

    • @tnikoli40
      @tnikoli40 4 роки тому +5

      @@johnnycashcow1130 this is my fear. Next friday i have an interview for a programmer/tester position where i will get 1 python and 1 c++ question. C++ is good cause i did lots of embedded while in college, but havent touched python in years. I know it will be sthing simple like make a function that does sthing easy but am afraid that i am gonna get sthing like this

    • @xrealy5700
      @xrealy5700 3 роки тому +5

      @@tnikoli40 how it went bro

    • @arphaksad01
      @arphaksad01 3 роки тому

      Depends on the industry

    • @DeepThinker193
      @DeepThinker193 3 роки тому +9

      @@tnikoli40 Bet they asked something like jane has apple in her basket and john has oranges in his. Calculate the distance of the sun to the moon and code how to use a rocket to get there.

  • @adabaladurgaprasad7926
    @adabaladurgaprasad7926 4 роки тому +95

    I regularly watch second threads UA-cam channel, but didn't know he was a facebook software engineer till now🔥

    • @chinmaym7479
      @chinmaym7479 4 роки тому

      Same bruh

    • @prateeksinghal630
      @prateeksinghal630 4 роки тому +6

      You should have checked his Facebook profile : p

    • @ironyman7015
      @ironyman7015 4 роки тому +5

      i though he was a student.

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

      @@ironyman7015 😂

    • @piyushpatel2347
      @piyushpatel2347 4 роки тому +1

      I regularly watch SecondThread videos and I knew since long back that he recently started working for FACEBOOK APP and was also a tester for Facebook hackercup

  • @MiketheCoder
    @MiketheCoder 4 роки тому +61

    He's a facebook engineer? I thought he was a competitive programmer student.

  • @NytronX
    @NytronX 4 роки тому +30

    Pro tip: You can name drop Aho in an interview, but never call the interviewer Aho.

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

    For those who want a simple alternative solution I made using JavaScript, not as advanced as the solution in this video, not using any special algorithms (after I heard the question, I decided to attempt it first before continuing the video) but I believe easier to understand, I have added in reply of this comment so that I don't flood this comment section, copy paste into a js file and use node to run it! :)
    If anyone have any comments that can help me improve on my code, do reply! I'm here to learn as well
    Explanations of my code:
    1. I used a lookup table (mapToNumber) because it's efficient and easy to understand, key value pair.
    2. I used multiple functions to try to make the code as clean as possible
    3. I made sure the functions in my code are pure functions (meaning return value is only determined by its input values)
    4. I used split function to determine if word exists, basically, after the split function, the returned string will change if the number string exists in the phone number, by literally using the converted word to number as the delimiter. so, example if foo = '366', the program will find the string 366 in the phone number, and if it exists, it will modify the phone number, and a check will come in to determine if the string has changed.

  • @the0dd1out_on_yt
    @the0dd1out_on_yt 3 роки тому +25

    Instead of doing complex Aho-Corasik, we can do a lil tricky hashing stuff here.
    Suppose N= all the characters in input.
    We will map all the substrings we find from given number of length less or equal to √N to find matching in the strings size less than equal √N and for bigger strings we can manually hash match each with the given number string!
    Complexity: N√N*(some log factor for mapping)

  • @CaptainSchlockler
    @CaptainSchlockler 3 роки тому +28

    Most convoluted approach to solving a problem I have ever seen. XD

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

    @clement, I love how you ask questions that's simple enough to solve within the timeframe but will get great signals out of the candidate. This will be testing people on their problem solving skills instead of how well they can prep for an exam.

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

      Second thought is that it's pretty cringe following through his interview since my thought process is very much top down compare to David's bottom up. So it's very interesting to see how we have such polarize types of engineers.

  • @sar6575
    @sar6575 4 роки тому +39

    David is an absolute god not only with his quick solutions but his coherent ability to explain things very simply is awesome !!!

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

      i assume ur experienced. why doesn't he just do
      let number = "3662277";
      let phonePad = ["", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"]
      let words = ["foo", "bar", "baz", "foobar", "emo", "cap", "car", "cat"];
      let works = [];
      for(var a=0; a

    • @karankumar89
      @karankumar89 4 роки тому +6

      @@warpromo6636 because 90% of Google, Facebook, Amazon interviewers are super anal about you giving an optimized solution using tree structures in 30 minutes that excuses without errors. ( they themselves wouldn't be able to do it, the irony). Which is why these interview methods are broken and outdated

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

      That Guy is a Mathematician!

  • @SyedAhmed-lv3kh
    @SyedAhmed-lv3kh 4 роки тому +38

    u guys had me at the part where u were explaining how the words correspond to the numbers :D

  • @rabinacharya8429
    @rabinacharya8429 4 роки тому +18

    I dont understand any of the logic here.
    Yet I enjoy watching the full video.🤣

  • @slayemin
    @slayemin 4 роки тому +102

    Damn dude, just go with the O(n^2) implementation and hard code the character to number conversion. There's no reason to worry about O(n^2) runtime when n is so small. If your code is simpler and takes less time to write, and isn't performance critical, it's more maintainable and easier to understand.

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

      I was thinking about pre-calculating numbers ahead like every common word(s) (there is like 300k words in english), storing them with certain hash/bite-encode (idk how to explain aka shortcut) and then only regular binary search or something as B+ tree, so it would take time in pre-calculating phase but after it it has O(log2) space requirment is worse but it's price that you pay for fast search? I hope it makes sense a little :D

    • @Smoothie128
      @Smoothie128 4 роки тому +16

      That is why you are not working at Google :D

    • @slayemin
      @slayemin 4 роки тому +73

      @@Smoothie128 Hah, you're right :) I work at facebook instead.

    • @hattapalkan8395
      @hattapalkan8395 3 роки тому +24

      @@slayemin dude stop you destroyed him

    • @farhanaditya2647
      @farhanaditya2647 3 роки тому +12

      @@slayemin bruh, that's brutal 😂

  • @khinljk
    @khinljk 4 місяці тому +1

    skill 100 %, code readability 100 %, communication 100%, you have nailed it 2nd tread, Google is knocking your door. : )

    • @zanies6288
      @zanies6288 2 місяці тому

      He probably doesn't want to switch. Every year he gets opportunity to set problems for mera Hackercup and commentate on it. Imagine getting paid to do what you love.
      Google stopped all it's cp contests

  • @alexIVMKD
    @alexIVMKD 4 роки тому +21

    Amazing... Really liked this one. Also, liked seeing some java.

  • @abtExp
    @abtExp 9 місяців тому +2

    This just gave me anxiety about my upcoming interview at google😮

  • @quachiecan6644
    @quachiecan6644 4 роки тому +216

    Could you do one with a “typical” college student in college? Usually these people you interview are 1%er’s if that makes sense and it makes me as a computer scientist on my second year of college super intimidated and inferior.

    • @rousseau327
      @rousseau327 4 роки тому +79

      But, to put it bluntly, that does nothing but make you feel better about your current situation in your career. Seeing a very competent Software Engineer tackle these problems helps you get a better understanding of how you should approach these interview problems.

    • @1andrew123
      @1andrew123 4 роки тому +32

      Dont compare yourself to these guys expecting to be this good.. do it to give yourself something to strive for. Accept where you are and keep taking baby steps and before you know it youll be here

    • @Jindujun
      @Jindujun 4 роки тому +16

      Just admire what people are able to do and strive to get better, thats all you need to do. Go your own path and don't chase after those guys.

    • @quachiecan6644
      @quachiecan6644 4 роки тому +13

      I feel like I might’ve not gotten my point across. I want to have a “typical” college student/person do it so I know how exactly they would go about the interview because I haven’t seen how THEY would go about the problems. Because everyone that has taken these mock interviews already know how to do it (for the most part) and breeze through it like nothing. The closest person we’ve seen to a “typical” interview was Tech with Tim’s.

    • @darksavior1187
      @darksavior1187 4 роки тому +3

      @@rousseau327 Sure, however, anyone soon to graduate and seek a new position are among the most likely demographic looking at these videos.

  • @TechnicalAnkesh
    @TechnicalAnkesh 4 роки тому +54

    David is a Great programmer!! he explains everything very nicely

    • @David-uc3cl
      @David-uc3cl Рік тому

      Thanks, wish everyone else would realize this

  • @aituganmirash2834
    @aituganmirash2834 4 роки тому +8

    Petition for Clement to add this question on algoexpert

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

    As a 18 year old with basics notions of programming, this makes me wanna spontaneously combust

  • @Akosiyawin
    @Akosiyawin 4 роки тому +27

    How impressive he knows such algorithms, How can he not forget that haha 😂

  • @RzariRzari
    @RzariRzari 4 роки тому +9

    So glad I'm working in small companies, don't deal with interviews like this and earn even better money

  • @codefallacy
    @codefallacy 4 роки тому +26

    when the interviewee brings out the big algorithms

  • @abhaypatil2000
    @abhaypatil2000 4 роки тому +15

    I have been watching his videos since a long time. I never knew he was in facebook. Congrats secondthread🤗🤗🤗🤗🤗🤗

    • @aj9706
      @aj9706 3 роки тому

      He is grandmaster. So it is meta

  • @nemotivity
    @nemotivity 4 роки тому +23

    Google Coding Interview With A Facebook Software Engineer who is wearing a Google T-Shirt! 😅

  • @xs-3
    @xs-3 4 роки тому +1

    I don't know why but i like the way this guy talks and explains things

  • @mangeshrananavare5656
    @mangeshrananavare5656 4 роки тому +7

    Tbh this could have been done in such a simple way. I dont understand why ppl dont simply use arraylist/maps and existing built in datastructures, which already have utility methods that make our life so much easier..
    None the less nice problem

    • @kira7741
      @kira7741 3 роки тому

      I would have used an arraylist here however I'm not sure how to compute the space time complexity. So maybe they're after the lowest time complexity here.

  • @mexicanmax227
    @mexicanmax227 3 роки тому +5

    I can see the Facebook engineers adrenaline rush as he solves it, passion!! Reminds me of when clement is presenting in a video, passion!! Social cues like these are always so awesome to notice, Passion!! lol

  • @sandeepnath9504
    @sandeepnath9504 3 роки тому +15

    That was pretty complex😵. If I were asked this question by an interviewer in some companies interview I would have said like the best possible solution to this problem is not trying for this company at all...!!!😂

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

      hahaha yeah... and for a simple phone number

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

      He overcomplicates it though IMO, maybe because he wanted optimal complexity idk .

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

      its not hard. You can solve it with a hash map . Its getting a super optimal sol that's hard

  • @anubhavbhadoria5737
    @anubhavbhadoria5737 4 роки тому

    Python beginner here. I didn't understand the solution given by SecondThread (as expected), so I created my own solution for it. (its working perfectly in my testing. It can also deal with phrases being longer than number.)
    def letter_to_number(letter):
    if letter in ("a","b","c"):
    return 2
    if letter in ("d","e","f"):
    return 3
    if letter in ("g","h","i"):
    return 4
    if letter in ("j","k","l"):
    return 5
    if letter in ("m","n","o"):
    return 6
    if letter in ("p","q","r","s"):
    return 7
    if letter in ("t","u","v"):
    return 8
    if letter in ("w","x","y","z"):
    return 9
    num = input("Enter number: ")
    phrase = input("Enter phrases [separated by a space]: ").split()
    res = [[letter_to_number(a) for a in i] for i in phrase]
    for i in res:
    if not("".join([str(a) for a in i]) in num):
    q = res.index(i)
    del phrase[q]
    print(" ".join([str(a) for a in phrase]))
    Let me know what you guys think!

    • @kevinleesmith
      @kevinleesmith 4 роки тому

      yep - but better using an array...
      For each word in words
      If instr(word2number(word), phoneNumber) > 0 then output word
      VBscript implemetation. Essentially 2 lines of code and 2 loops...
      ...
      0 then response.write word & ", "
      next
      %>
      See it working at https:/pragmatic365.org/google-interview.asp
      The whole idea of software engineering is to write as LESS lines of code as possible, not the most!!!
      But what do I know.
      I've only been coding for 42 years.

    • @anubhavbhadoria5737
      @anubhavbhadoria5737 4 роки тому

      @@kevinleesmith Thanks a lot for your message. At the time of writing my previous message I did not know any way other than (if) to convert letter to num. Later, I learned about dictionaries and used that. l . My latest code (inspired by your code) is pasted below. This is as compact as I could make it :) Maybe one day I'll learn enough to also do the aho-corasik way. Thanks for your time.
      def word_to_num(word):
      key = {'a':2,'b':2,'c':2,'d':3,'e':3,'f':3,'g':4,'h':4,'i':4,'j':5,'k':5,'l':5,'m':6,'n':6,
      'o':6,'p':7,'q':7,'r':7,'s':7,'t':8,'u':8,'v':8,'w':9,'x':9,'y':9,'z':9}
      return "".join([str(chr) for chr in[key[chr] for chr in word]])
      num = input("Enter num: ")
      phrase = input("Enter words [separated by space]: ").split()
      for word in phrase:
      if word_to_num(word) in num:
      print(word, end=" ")

  • @chloeagape4853
    @chloeagape4853 4 роки тому +6

    cool! I actually came up with like 75% of the solution before seeing what he did. I was stuck at figuring out how to backtrack back once you've explored a path, and I guess there was a fancy algorithm (aho) that finds the fail links. In a real interview, I guess leaving out the aho algorithm would be ok as long as you were able to mention and talk about it.

  • @ZCxMusic
    @ZCxMusic 4 роки тому +33

    I already have a job in programming but watching this still makes me shit my pants.... I'm very far from his level

    • @aj9706
      @aj9706 3 роки тому +1

      I don't have a job bro I am from india.

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

      @@aj9706 I am laughing at all you people! reading the comments like i know everything! i don't know why LMAO

  • @mattconrad
    @mattconrad 3 роки тому +8

    LOL @ Clem's reaction when SecondThread says "Aho-Corasick" for the first time 😂

  • @fyiwdt
    @fyiwdt 4 роки тому +1

    That was fun. But in real interview this can be a really dangerous strategy, because interviewer must be ready for such turn of events. And Clément pointed that out, thanks.

  • @PraveenKumar-lp6il
    @PraveenKumar-lp6il 4 роки тому +5

    After watching 30 mins I can't even under the question 😅😅🤣😂

  • @vikramc.n.1121
    @vikramc.n.1121 4 роки тому +10

    Looking smart in this hair style sir. Also thank you for being such an inspiration person and thank you for helping us with your awesome videos

  • @davidkezi6086
    @davidkezi6086 4 роки тому +6

    watching this, i don't know if i can ever be this good

    • @chris9352
      @chris9352 4 роки тому +1

      Why not?

    • @MrRushifyIt
      @MrRushifyIt 4 роки тому +6

      It's a really bad habit to compare yourself to others. David is "this good" because he focuses his attention on learning and teaching rather than doubting his ability. You should watch this and feel inspired to learn!

    • @kokoriko580
      @kokoriko580 4 роки тому +1

      you know, im so so happy when i created login form (not reaponsive) with simple html and css.
      if i compared myself to this guys, im nothing, but remember, there are people below you cant do things you do right now..
      but im still hoping that i can be as good as this guys, i wont compare myself tho, but i learn from them..

    • @chris9352
      @chris9352 4 роки тому

      Analogy:
      If you never learned how to ride a bicycle, the beginning of you deciding to ride one will be rough and make you wonder how is it even possible to have such control/balance on that 2 wheels thing!
      But if you perceiver you will eventually get to a point where you start getting it right because it's not magic but rather all about adaptation.

    • @fluttersulan291
      @fluttersulan291 4 роки тому +1

      They practiced years for this kind of stuff and all they do afterwards is pattern matching and reuse the knowledge they already have. Mostly they lack some other concepts in CS.
      So don't think like that, just start solving some problems on yout own and you will see that it will get easier and easier.

  • @ColinGordon-u4y
    @ColinGordon-u4y 10 місяців тому

    Simple solution is to make a hash from letter to number.
    Use hash to generate string
    Use regex number match hash(letters)
    Complexity is less than (number length)*list converted
    Where the conversion is average word length times number of words

  • @caralmar1
    @caralmar1 4 роки тому +8

    JavaScript can do this very quickly with built-in functions.
    Step 1, create an object (which is searchable) that has each letter mapped to a corresponding digit.
    For example:
    var digits = {};
    digits.a = 2;
    digits.b = 2;
    digits.c = 2;
    digits.d = 3;
    ...
    Step 2, simple for loop that converts words in given input array to numerical representation:
    for (var word in words) {
    numbers.push(words[word]
    .split("").map(function(item) {
    return digits[item]
    }).join(""));
    }
    Step 3, return result by using "includes" function and filtering out nulls from the map:
    result = numbers.map(function(item, index) {
    if (phoneNumber.includes(item)) {
    return words[index];
    }
    }).filter(function(item) {
    return item !== undefined;
    });
    return result;
    While my solution may not be the fastest, given the easy readability and maintainability of the resulting code, I would opt for that solution over a more esoteric node approach. Just my 2 cents!

  • @coryschallert8915
    @coryschallert8915 3 роки тому +1

    This is awesome but terrifying at the same time. This "Mock Interview" will lead to much bigger "applications" in the real world.

  • @dinckelman
    @dinckelman 4 роки тому +10

    Clément: Coding interview done by regular mortal
    Also Clément: Our interviewee today is a professional competitive programmer with multiple known wins
    Anyone else see the problem here?

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

    Thank you Clement the video helped in giving an overview of how to communicate our ideas during an interview

  • @gitlit5489
    @gitlit5489 4 роки тому +11

    i want back my educational round explanations

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

    The most delightful coding editor out there -- google docs.... lolllllllll

  • @harispapadopoulos4295
    @harispapadopoulos4295 4 роки тому +4

    oh man, the excitement I get every time I see the notification that clement uploaded a new video

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

    Aho-jurassicpark wtf. This dude just out here spitting theorems

  • @abcdxx1059
    @abcdxx1059 4 роки тому +11

    After 1 and half month of leetcode I'm actually able to solve this on my on 🥺🥺🥺last time I watched your video on this topic i thought i will never be able to solve these questions . If you're in the same spot don't give up you need to practice these questions and after sometimes you will be able to spot patters and solve the problems

    • @ribashkarki126
      @ribashkarki126 4 роки тому

      Is leetcode free or have to pay for it?

    • @amitpanthi8643
      @amitpanthi8643 4 роки тому

      @@ribashkarki126 It's free for the most part. Some questions are locked behind a paywall, but the pros easily outweigh the con

    • @mitpoker7319
      @mitpoker7319 4 роки тому

      What are you waiting for? get a job at google, already...

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

      Quick question! Back when you were a noob, and solving the leetcode questions, how long did it usually take you to finish the questions.
      Noob here, and it takes me an hour or two (even more) to solve questions which I haven't seen before

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

    I don't understand anything but still watching it.
    Guys don't give up🥺

  • @sanketsaxena3558
    @sanketsaxena3558 4 роки тому +16

    Please try to call gennady korotkevich on your channel for these kind of google interview.. It will be fun to see how he see these interviews..

    • @-_RonyMir
      @-_RonyMir 3 роки тому

      Watch his live streams instead!
      His solution's r just out of the box! I dont even dare to look at his code!!🙄

  • @hellobro8837
    @hellobro8837 3 роки тому

    Someone like clément can only put ad of his own company in his video.

  • @ryangulati5872
    @ryangulati5872 4 роки тому +21

    Hey Clement, do you have a front end expert in the works? I would totally buy that!

  • @naveenverma2390
    @naveenverma2390 4 роки тому +21

    FINALLY ONE JAVA CODER

  • @raheenulhasan
    @raheenulhasan 3 роки тому +23

    The solution I had was-
    1. A Map to store letter, numeric pair. Total keys 26.
    2. Take a word, convert it to numeric equivalent value.
    3. Check if phone number string contains this equivalent value.
    I think this is a simpler approach.

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

      well this is not javascript it depends on which language you use. regardless he thinks on the spot and he has very good ability to communicate his thoughts which is the difference why he works at places like google, (in his case, facebook) and other people like on here, who "brag" that they can do it in much better way...but cant land a job at Starbucks because, can't speak their name properly ;/

    • @raheenulhasan
      @raheenulhasan 3 роки тому +12

      @@milovanmilovanov2598 @Milovan Milovanov Did you see that I started the comment with "The solution I had", this was in no way demeaning to anyone and let alone you. I don't get why you got triggered and basically started ranting about stuff. Btw I did try it and when I got it, only then I posted this comment. Well your comment was distasteful here. On the name comment, please choose to accept people with different backgrounds and places trying to make the best softwares available.

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

      I was thinking of something like this, too, but I'm thinking in python terms here. His solution is in my eyes - though appearing unnecessarily complex - actually much more elegant, as he does not check the words one by one, but all of them at once. Using a BFS here to navigate the graph of failure edges provides a major advantage when it comes to datasets much larger than the ones used for example here, as you basically build a "frontier" moving through the graph. It gathers much more results in one go.

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

      Yeah, but it had to be faster. He reduced complexity. Nice job by the way 👍

  • @Aks-47
    @Aks-47 3 роки тому +2

    waiting for a HEALTHYUG google coding interview round!

  • @euclid9492
    @euclid9492 4 роки тому +17

    It’s funny watching him solve this. I would have immediately confidently said make a 2D array with each sub array holding the chars that the given phone number digit maps to. Then go through one at a time through the chars in the word we’re looking at and use a nested for loop to compare that char to the set of letters the current phone digit maps to. If a char matches, check the next letter in the word with the next set of chars. If chars match, the word is a substring. Upon first mismatch exit and do the next word. Do this for the length of the word we are comparing. Do this with a sliding window hence the nested loop. Now that I think about it that’s probably the slowest possible O(phone#length^2•wordLength)solution. 😂 I wouldn’t have thought to ask if the phone number can be more than 10 numbers either so I maybe would have thought this to be acceptable. I’m just getting my head around coding graphs and hash maps, I guess Tries are the next iteration in my data structure learning path. We skipped it in my data structures class but it seems very useful.

  • @frankyoung4980
    @frankyoung4980 3 роки тому

    He named the children nodes as kids because kids are much shorter to type, which is smart especially in a time critical coding interview using a doc.

  • @Clashtoons
    @Clashtoons 3 роки тому +34

    That was cool

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

      WHAT ARE YOU DOING HERE LOL?

    • @Clashtoons
      @Clashtoons 3 роки тому

      @@peepoHappyy if you have watched my videos, and looking my comments in this geeky thing. Then I can imagine why would you be amused. Can I ask. Is it that the case? That would be awesome😂

    • @peepoHappyy
      @peepoHappyy 3 роки тому

      @@Clashtoons Man, I mean you make cartoons and such, why are you on a video about a coding interview?? 😂

    • @peepoHappyy
      @peepoHappyy 3 роки тому

      Also, your cartoons are one of my pure nostalgia. Keep up the amazing work!

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

      @@peepoHappyy I make cartoons as an hobby and do coding also as an hobby and a profession. Thank you. This is the first time me being "recognised in public" moment for me.

  • @Grr1967
    @Grr1967 4 роки тому +1

    Great video. One thing I learned is that black t-shirts are mandatory for both interviewer and interviewee :-)

  • @AmanDeepSingh-xe9of
    @AmanDeepSingh-xe9of 4 роки тому +9

    The question seems simple, but boy the solution went over my head :(

    • @counterleo
      @counterleo 4 роки тому +3

      Yeah man, I coded a solution that's extremely simple really quickly with no fancy data structure or algorithm and I got the right output, not sure about the complexity though

    • @khmiri
      @khmiri 3 роки тому

      I think he was showing up... I solved it in a few numbers of code tho

  • @JohnCodes
    @JohnCodes 4 роки тому +3

    Might as well start rounding out FAANG with some netflix, airbnb, etc interviews!

  • @siouxperirish
    @siouxperirish 3 роки тому +13

    I enjoy the format of these interviews and I’m curious if you as the interviewer, would be open to redefining the approach to attacking this toward a solution. If you or others would generally be open to allowing the interviewee basically change the use case to begin with the end defining the beginning. If your eyes haven’t glazed over yet, what I mean in this situation is to try and convince the interviewer up front; agree on an assumption which would reduce complexity. I realize you’re looking for construction ability, complexity, quality, efficiency, but if you could agree ahead of time on a logic-based route to completion, before coding begins, then I would say I would provide the customer all the available phone number combinations they could choose from, as the output and ask them to enter their word since they’ve probably settled on a company name and just need to find a number that can represent the name.
    Not targeting this instance in particular but I guess I am. Overall, would this taint the interview or would this generally be thought of positively, a perspective employee pushing back a bit right up front. I know for me, I try to dumb the complexity down (for lack of a better phrase), so I can begin with what feels like my idea or my internal translation of the ask. Thanks and sorry if I’ve bored everyone with my question.

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

      Would love to hear Clement's answer to this question as this very situation happens... essentially with every project in software design and consulting.

  • @dev-skills
    @dev-skills 3 роки тому

    Great to see you are sticking to primitive int arrays instead of Arraylist

    • @dev-skills
      @dev-skills 3 роки тому

      Towards the end you used ArrayDeque which might upset interviwers who dont have java background.

  • @steve680
    @steve680 4 роки тому +3

    You should try running the code to see if it actually works. This is one of the problems with these whiteboard exams. And you should have him comment his code too.

  • @kavitharajni8962
    @kavitharajni8962 3 роки тому

    i solved this problem by myself. I am 13 years old. I believe that anyone can do it if u have the passion and determination

    • @Fanta....
      @Fanta.... 3 роки тому

      Protip, just buy some crypto and retire early. much easier.

  • @jaysizmir9432
    @jaysizmir9432 4 роки тому +4

    his explanations was super clear, amazing !

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

    I don't know anything about coding (but planning to learn about it), so thinking about this problem and then following along with how the candidate approaches it was super interesting to me.

  • @zik9326
    @zik9326 4 роки тому +8

    am i waste my time while watching this without understanding. . .
    and no idea why i still watch till end.

    • @MrRushifyIt
      @MrRushifyIt 4 роки тому

      It is definitely not a waste of time to watch this! you watched this because you are interested and curious. =D

    • @zik9326
      @zik9326 4 роки тому

      @@MrRushifyIt yep true. also confused coz im just learn English language and learn program language which language should i learn first?😂

    • @fluttersulan291
      @fluttersulan291 4 роки тому +1

      @@zik9326 It doesn't really matter which language you learn first. Just make sure, that you learn the concepts behind them, because all programming languages share some concepts, only the syntax is different.
      Start with Python and learn by making some projects, than learning plain syntax. If you want challange yourself go with C++, it can be hard at the start, but after you made it threw some concepts it is pretty easy afterwards and switching to another languages will be much easier for you.
      GL and have Fun!

    • @zik9326
      @zik9326 4 роки тому

      @@fluttersulan291 wah thanks brother. it means a lot for me.

  • @XnazxulX
    @XnazxulX 4 роки тому +1

    This is such a good question. I wish i was smart enough to be able to look at something and come up with n number of algos off the top of my head that would be a candidate for it. Love your interviews.

    • @MrRushifyIt
      @MrRushifyIt 4 роки тому +1

      you can be that smart! You just have to surround yourself this sort of content and build up a knowledge base. look at his github repo at 47:49. When he hears about an algorithm, he does some research on it, then tries to implement it himself, then saves it in his collection. Always be curious and willing to try new things, you'd be amazed at what you can accomplish.

  • @sarthaknikhal5540
    @sarthaknikhal5540 4 роки тому +18

    Clement be like, "I know you work in a cool company but let's see if you're eligible to work at another cool company!" 😂

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

    It’s easy but very understandable explanation.

  • @skdx1000
    @skdx1000 4 роки тому +4

    this is perfect timing because i had to implement aho-corasick for work last week!!!!

    • @Garentei
      @Garentei 4 роки тому

      What kind of work do you do? Lmao

    • @skdx1000
      @skdx1000 4 роки тому +1

      @@Garentei i am an nlp engineer and implmenting/designing fast text search is part of daily work lol so this kind of stuff comes up very often. i deal with graphs and trees daily lol

    • @Garentei
      @Garentei 4 роки тому

      @@skdx1000 Cool!

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

    Just so people don't get discouraged. These types of interviews are not just about natural skill but also memorization. Because unless you've actually seen and implemented an Aho-Corasick algorithm then you would've probably had a very hard time in this interview.

  • @daark3113
    @daark3113 4 роки тому +24

    *Facts about clement*
    Everyone: He worked at google and Facebook.
    Me: He has a secret Black V-Neck shirt collection

  • @Chris-qg6kc
    @Chris-qg6kc 3 роки тому

    Let me go ahead and use that “phone-a-friend” algorithm

  • @satyampatidar5848
    @satyampatidar5848 4 роки тому +10

    David (aka second thread) completed his bachelor's degree in 2020.
    And now he is full time Engineer i think

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

    Please keep doing sessions like this

  • @ab123232
    @ab123232 3 роки тому +3

    what im actually worried about is: this is the type of questions a fresh graduate student will face in interviews? Or what exactly am facing

    • @prim.x
      @prim.x 3 роки тому

      No, in fact, what you see here is a simple version of the question. People usually see harder questions.
      This is what separates us Real developers from the Kid developers.