Google Coding Interview With A Facebook Software Engineer

Google Coding Interview With A Facebook Software Engineer

Clément Mihailescu

3 года назад

921,285 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Asagi Ai
Asagi Ai - 13.08.2023 05:15

I probably gonna use some sort of hashtable or dictionary.
Then, use some sequence of logic, true or false. Using And (logic) and length of the word.

I won't code here. But the idea is
1.) Use a hash table
2.) Iterate through the given input number
3.) Use some kind of mark numbers ex 1 if it is contained, 0 not contained -1 not yet
4.) Some logic here.
5.) Return the word if word have sequence of 1's the same as the length of the word

Just an example foo and baz
Foo. Baz
3 (def) (1) (-1)
6 (mno) (1) (-1)
6 (mno) (1) (-1) add foo to the list because the sequence of 1 from the end is not broken.
2 (abc) (1)
2 (abc) (1)
7 (pqrs) (0) don't add Baz to list because the sequence of is broken also we encounter 0.

Ответить
Shubham Sharma
Shubham Sharma - 03.08.2023 16:44

good video

Ответить
Pulkit Malhotra
Pulkit Malhotra - 05.06.2023 11:48

One suggestion: @clem kindly provide the question link.

Ответить
Pulkit Malhotra
Pulkit Malhotra - 05.06.2023 11:47

It is a CP level questions. I don't think companies usually ask this question in interviews.

Ответить
KASIRU YAMAGATA
KASIRU YAMAGATA - 15.05.2023 17:28

Damnnnn. Never thought of applying segment tree in this qn. Cp is HARD

Ответить
Horia
Horia - 03.05.2023 21:31

easy problem, I could solve in 15 minutes, much simpler, but I don’t know how the performance would be compared to this guy, and in python not C.

Ответить
Ebtasam Faridy
Ebtasam Faridy - 11.04.2023 02:14

KMP over all strings assuming m string and maximum length of phone number and each string be n will take O(m*n),
on the other hand Aho-Corasick also takes O(sum of all length *10) ie O(m*n) time only,
isn't Aho-Corasick is beneficial only in case if length of all m string are small as compare to n ?

Ответить
Saturn_TeaTree
Saturn_TeaTree - 03.04.2023 00:24

Logically i would just convert the number into letters and do like a search for each word 🤷🏾‍♀️

Ответить
Saturn_TeaTree
Saturn_TeaTree - 03.04.2023 00:19

Um poor thang was struggling the first ten minutes let me try to solve it and come back to watch 😂😂😂

Ответить
Gabe Alexandr
Gabe Alexandr - 24.03.2023 11:22

Any tips for someone learning to code but really good at math… I.e I got the science part down just not the computer part. Most I’ve learned to do so far is code a Rock Paper Scissors game against a computer(rng)

Ответить
the realG
the realG - 03.03.2023 22:16

bruh I just used a hash map. Never heard of this Aho algorithm. My time complexity is definitely slower

Ответить
Auraphonic Limited
Auraphonic Limited - 02.03.2023 17:17

I'm looking at finding a job in software engineering or data engineering. I have no experience with technical interviews and am looking to see if I am ready to take one on should i be progressed. i came up with a simple solution to the problem before watching the rest of the video. After watching the video the answer given was very complex (at least for me currently). Would a simple solution be OK in this situation or are you expected to give a more in-depth answer like in the video?

Ответить
satriahrh
satriahrh - 28.02.2023 08:09

Can't keep up with the answer, to difficult for me T_T

Ответить
rotteegher39
rotteegher39 - 30.01.2023 10:42

Interview: tea tea bee tea hey bee tea tea

Ответить
Cherry The Gamer
Cherry The Gamer - 19.01.2023 14:42

solved this in 10 mins with two algorithmic approaches

Ответить
Rishabh Dwivedi
Rishabh Dwivedi - 07.01.2023 03:39

Will KMP work here

Ответить
Entice
Entice - 15.12.2022 03:31

WHAT .Language is he coding in

Ответить
Pablo Lopez
Pablo Lopez - 13.12.2022 21:31

@clem There is a much much faster and easier solution. Find the first 10^n that is above the number to search. Calculate phone % 10^n. If does not match, divide phone by 10.
Example: Search CAR (227) in 3662277.
The 10^n just above 227 is 1000.

3662277%1000=277
366227%1000=227 <--------- FOUND!!!

Can i enter Google now? ;)

Ответить
Masha B
Masha B - 12.12.2022 23:29

my solution for this problem: (only tested with the input in the video):

function wordsContained(phNumber, words) {
const ltrs = ['', '', 'abc', 'def', 'ghi', 'jkl', 'mno', 'pqrs', 'tuv', 'wxyz'];
const res = [];

for (const word of words) {
if (isContained(word, 0,0)) {
res.push(word)
}
}

return res;

function isContained(word, phDigit, wordIdx) {
if (wordIdx === word.length) return true;
if (phDigit >= phNumber.length) return false;
const letters = ltrs[phNumber[+phDigit]];

if (letters.indexOf(word[wordIdx])!==-1) {
return isContained(word, phDigit, wordIdx+1)
} else {
return isContained(word, phDigit+1, wordIdx);
}
//return false
}

}

Ответить
PyAjudeMe
PyAjudeMe - 02.12.2022 07:27

This exercise can be solved with a single line of code: result = ["".join(list(i[0])) for i in zip([tuple([str(y) for y in x]) for x in words],[tuple([str(phonedict.get(y)) for y in x]) for x in words]) if i[1] in tuple(set.union(*[set(q) for q in [[pp for pp in p if pp in [tuple([str(phonedict.get(y)) for y in x]) for x in words]] for p in [[k for k in wordsasnumberx] for wordsasnumberx in tuple( (((itertools.combinations_with_replacement(list(str(tele)),r=x)))) for x in range(0,len(str(tele))))]] if q])) ]


# if we only count the algorithm :) , the whole code has 5 lines
import itertools
tele=3662277
words=['bar', 'foo', 'car', 'cat','foobar','cap','emo']
phonedict={'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, }

result = ["".join(list(i[0])) for i in zip([tuple([str(y) for y in x]) for x in words],[tuple([str(phonedict.get(y)) for y in x]) for x in words]) if i[1] in tuple(set.union(*[set(q) for q in [[pp for pp in p if pp in [tuple([str(phonedict.get(y)) for y in x]) for x in words]] for p in [[k for k in wordsasnumberx] for wordsasnumberx in tuple( (((itertools.combinations_with_replacement(list(str(tele)),r=x)))) for x in range(0,len(str(tele))))]] if q])) ]
print(result )
['bar', 'foo', 'car', 'foobar', 'cap', 'emo']

Ответить
Expert System
Expert System - 27.11.2022 18:59

He will create a graph that know adjacent nodes based on the list of elements, then match the phone number nodes. 🤪 Why don't just convert the dam input list to number string and just check if it existing in phone string? 😂

Ответить
B
B - 27.11.2022 06:56

Hit me on my pager you better have a code lol

Ответить
Prem Thapa
Prem Thapa - 10.11.2022 16:28

I just started to learn to program . Is it just me that felt this was an easy one ?
I have my own solution to this
Just let me know if my noob ass just misinterpreted the question

ref = { '2':'abc','3':'def','4':'ghi','5':'jkl','6':'mno','7':'pqrs','8':'tuv','9':'wxyz'}
words = ['foo','bar','baz','foobar','emo','cap','car','cat','prem','clement','clemdot']
def practice(words,Number,ref,n=0):
if n==len(Number):
return words
considered = []
for i in words:
if len(i)>n and i[n] in ref[Number[n]]:considered.append(i)
return practice(considered,Number,ref,n+1)
Its based on recursion and n is the index that we need to check and works good on all cases i tried .Please do leme know if im mistaken

Ответить
Otto Diesel
Otto Diesel - 08.11.2022 22:21

Programming is a life denial occupation

Ответить
John Ames
John Ames - 06.11.2022 04:31

20yrs ago my friend came from india as a software engineer hired by Ford on H1-B visa, he wouldn't have been able to do any of this. Back then if you could write a function and use a Sam's book or "bible" to find a method you were a hireable software engineer.

Ответить
ExtremelyTastyBread
ExtremelyTastyBread - 02.11.2022 03:37

Would you guys study things like this if you didn't need to do it in order to get high paying jobs? I want to off myself before the video is even over

Ответить
Per Persson
Per Persson - 19.10.2022 15:10

Going directly for a complicated algorithm is seldom recommended. Usually data is small and a simple and straightforward solution works fine. In this case, the phone number can be expected to be relatively short, not more than 20 digits. The words will also be short. But the number of words might be large. Therefore, it's probably okay if the algorithm is O(N²) in the length of the phone number, but it should be O(N) in the number of words.

Ответить
Anthony Taylor
Anthony Taylor - 16.10.2022 12:23

Google can just keep their job if this is what they expect.

Ответить
Anthony Taylor
Anthony Taylor - 16.10.2022 12:20

Do I really need to be this good at algorithms to get a job at Google these days? That’s just honestly discouraging.

Ответить
aya solaris
aya solaris - 07.10.2022 18:45

I like your funny words Mr Aho man

Ответить
Ersin Erdem
Ersin Erdem - 21.09.2022 17:07

the weird part is how he sees the trie as a trivial thing. If I consider using a trie in a problem, I feel happy that I could think about it :D

Ответить
haocherhong
haocherhong - 18.09.2022 07:47

kids 😄😄

Ответить
Roger
Roger - 26.08.2022 22:18

Nice work you're hired! Now go turn this button green.

Ответить
kenxin Hxc
kenxin Hxc - 21.08.2022 05:36

I don't understand any shits here but still enjoy watching

Ответить
lpm learning
lpm learning - 20.08.2022 18:14

This is the most stupid type of question one could receive in a coding interview, and here I’m referring to the part “any length of a phone number”. This just breaks the principle behind the exercise and the idea itself of translating the phone number. The industry is being led to an assured destruction moving forward like this. It feels like it’s past the time when Google was this kind of geeky, community-feel type-of-place where you’d code up something cool and it would then become a useful tool used by others. It’s ridiculous, and at fault is the recruitment industry that turned the most vain ideologies (“ex-this”, “ex-that”, etc etc) which makes one work 10x as hard as you used to before JUST to land an interview. It’s long past the time when your average SWE working at some medium-sized company developing websites would “volunteer themselves” into Google to create, or help create, “cool things used by millions across the globe”. I’m just so sick and tired of it. Looking for a job becomes a full-time thing in itself. Just drop it guys… It’s hurting the industry.

Ответить
SANGKAY EBOY
SANGKAY EBOY - 19.08.2022 06:11

i'm going shifting from technician to test dev eng'g works. very interesting to see dis tuts

Ответить
Mikael Pettersson
Mikael Pettersson - 18.08.2022 13:56

I would have just simplified the problem to find() in the string phonenumber after I recoded the words in the arraylist. I would have failed so bad : )

Ответить
Adwait Naik
Adwait Naik - 13.08.2022 15:25

Time while attending a coding interview goes faster than time watching someone else doing it.

Ответить
DANIEL KAKAI
DANIEL KAKAI - 09.08.2022 22:35

Just got hit by imposter syndrome

Ответить
Мустафа Исламов
Мустафа Исламов - 31.07.2022 15:21

Man... I dont know shit. Thanks for the realization, great video xd

Ответить
phaedrusalt
phaedrusalt - 30.07.2022 03:04

The optimal solution requires you to turn it around, find the digit representation of the words (As a string), then search for that digit-string in the original number. You lose the one-to-many complication this way, and it can be done with much less code.

Ответить
Ahsan Sohail
Ahsan Sohail - 25.07.2022 21:52

I think interviewer doesn't even verify what is typed is correct, he hasn't gone through any edge cases or anything, he be like you filled the doc it must be correct

Ответить
leo mak
leo mak - 25.07.2022 02:34

I would never hire this guy ) he cant make simple solutions that work

Ответить
Bradley Erickson
Bradley Erickson - 23.07.2022 00:40

Damn I have been a dev for like 8 years. There is no way I would pass an interview like this 🤣🤣🤣

Ответить
raunak tamang
raunak tamang - 22.07.2022 19:18

Man!! what a 50 min horror show, chills all over my body and that godly alohomora shit!!

Ответить
Christos Perivolaropoulos
Christos Perivolaropoulos - 21.07.2022 23:08

Pretty cool that he implemented the hard algorithm I hadn't seen that one on a while but I think other commentators are correct to point out that the interview process has gone out of control but I like this particular problem because imo Dave is a bit too smart for his own good here, an experienced software engineer would have come up with a much faster solution which happens to be the naive one with a few bells and whistles:

two digits can comfortably fit in a byte so 15 digits can fit in 8 bytes which a modern processor can compare in one instruction. Encoding the phone number and the words into 32bit integers and then carefully shifting and comparing is extremely efficient on modern hardware. On the other hand trie traversals cripple speculative execution and the ROB usage, modern CPUs hate hierarchical data structures (or more precisely they love simple ones).

In this particular problem we would probably not have too much of a cache miss/page fault problem but generally that is another important concern with hierarchical datastructures.

I guess there is some important advice to be extracted here: asymptotic complexity virtually always lies. If we were dealing with platonic Turing machines maybe it would be important but taking advantage of the actual material conditions of the problem is what imo makes a really good engineer.

Ответить
Piyush A.Supe
Piyush A.Supe - 14.07.2022 19:53

map foo to number string "366" then if(strstr(phonenumber, "366") !=null), match found.. hurray 😀. PS: Just Kidding

Ответить