Unsyndicated: A Google Interview Question
source link: https://jrms-random-blog.blogspot.com/2021/03/a-google-interview-question.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
A Google Interview Question
When I was working at Google I had to interview a lot of candidates. Most often the interview was general in nature. I wasn't evaluating a candidate for a particular position, I was determining whether a candidate was all around "Google material".
Although Google is known for its challenging interview questions, I found the simple questions gave me the most information about a candidate. One of my favorite interview questions was this: “Given the state of a tic-tac-toe game (naughts and crosses), determine if someone has won the game. Code this up however you'd like.”
This isn't a very hard problem. (Pause a moment and think how you'd do it, or even take a moment to write it up.) The straightforward solution is to check the rows, the columns, and the two diagonals. I was less interested in whether the candidate would come up with this solution or something more clever than I was in seeing exactly how the candidate worked his way from an informal word problem towards a formal solution in code. I wanted to see how the candidate organized his thoughts. I wanted to see how proficient the candidate was in programming when he was allowed to use the language he was most comfortable with.
I expected most candidates to whip off a solution in a few minutes and then we'd move on to the next interview question. To my surprise, fully half the candidates were unable to finish this simple task. A couple seemed unable to use a whiteboard to sketch out a solution. A large number dove right in and started coding up the obvious nested loop only to get confused at handling the flow control. (There is a hidden trap in this problem: if you choose the nested loop solution, you want to abort the inner loop early when you determine a solution is not possible on the current row or column you are checking, but you want to abort the outer loop early when you determine a solution is possible.) It was often that a candidate did not at first realize that a cell in the tic-tac-toe board has three possible states, not two. One candidate used 4x4 arrays to represent the board so he could use 1-based indexing. Not a single candidate tried to abstract over the low-level array manipulation.
Interviews are highly stressful for candidates, so I didn't judge them too harshly. If it looked like they were on the right track and they successfully noticed and repaired a bug or two in their solution I'd call it a win. If they got hopelessly lost, I'm afraid I couldn't recommend them. It was sad because many seemed very nice people and they were trying their best. Either they weren't cut out to be programmers or their education was not serving them well at all.
I do have to mention one candidate who knocked this question out of the park. He observed that there really aren't that many tic-tac-toe game positions, so you can just hash the game position and look up the winner in a table. I didn't even ask him to code this up.
Recommend
-
67
README.md Python基础 1、文件操作 1.1、有一个jsonline格式的文件file.txt大小约为10K 1.2、补...
-
50
Photo by Amy Hirschi on
-
40
The process of preparing for coding interviews is anxiety-inducing for many developers. There’s so much material to cover, and often m...
-
25
Introduction The two-sum interview question is interesting to explore because it has both a brute force, logical solution, as well as a more time-efficient solution that can demonstrate strong computer science fundamentals. Let’s explore...
-
11
John Fremlin's blog: Pagination, a great software interview questionWaiting for updates: connectedPosted 2017-05-05 22:00:00 GMTExperienced, highly productive, senio...
-
5
My Most Useful Technical Interview Question
-
18
Follow up questions in interviewsMany interviewers ask follow up questions after the interviewee gives their initial answers. Don’t get nervous if you get follow up questions. Being asked follow up questions doesn’t...
-
11
Candidates for many of the jobs at Amazon, those Level 5 and above, receive a writing exercise that’s due before their onsite interview. Amazon gives this test because candidates need good writing skills to work there.What you need to...
-
13
Even if you prep enough for your interview you may still get a question you don’t know how to answer. What should you do if this happens? Don’t panicI know this situation is everyone’s interview nightmare, but you can handle i...
-
9
@ggorantalaGopi GorantalaI had roughly 10 years of experience under my belt -- working in Belgium for half a decade.
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK