15 ms·
Coding Interview Tips
- bcjordan 13y agoThis is a really comprehensive list of tips, thanks Parker! Definitely including this in next week's Coding for Interviews newsletter.
- losethos 13y agoKnow what's funny? My compiler did yoda conditionals wrong for the first 4 years, or so! I never noticed because I never use yoda conditionals with a constant. When you compare to an immediate, you probably want to flip the conditional so you always use the same asm CMP. I just inverted the logic when I had a yoda if (5<I) if (I>=5) That is not correct! I didn't notice for 4 years! ----- I've been in hotel California -- no feedback --no emails. Everything is full of bugs. I don't give a fuck.
- dhammack 13y agoJust as a heads up, after I finish an interview question neither button works (I'm an expert or review later). Clicking on each doesn't seem to do anything. The only way for me to see additional questions is to head back to the homepage and re-click 'run some practice questions.'
- gameguy43 13y agoThanks for the report! Having trouble reproducing on my end ... are you logged in?
- dhammack 13y agoYes, I am. Here's what shows up in the dev console when I click "I'm an expert" PUT http://www.interviewcake.com/api/v1/viewings/ http://www.interviewcake.com/api/v1/viewings/ 403 (FORBIDDEN) angular.min.js:99 (anonymous function) angular.min.js:99 n angular.min.js:95 l angular.min.js:94 DjangoRESTResource.(anonymous function) angular-django-rest- resource.js:12 DjangoRESTResource.(anonymous function) angular-django-rest- resource.js:18 $scope.updateViewing base.js:31 $scope.markAsComfortable base.js:13 $scope.feelExpertPress base.js:15 (anonymous function) angular.min.js:72 (anonymous function) angular.min.js:144 e.$eval angular.min.js:88 e.$apply angular.min.js:88 (anonymous function) angular.min.js:144 x.event.dispatch jquery.js:5095 v.handle
- gameguy43 13y agoGot it. Digging into this now. Meantime, you might try another auth method? There's also this secret page to walk through the questions by hand: http://www.interviewcake.com/all-questions http://www.interviewcake.com/all-questions Sorry about that!
- ceautery 13y agoSame problem. Looks like we're getting a 403 posting to the server after the initial question. I'm logged in with G+.
- fvrghl 13y agoI'm also having the same error
- BellsOnSunday 13y agoSelecting cancel during the login results in a 500 error and long list of django debug information that you might want to tidy up.
- gameguy43 13y agoThanks for the report. Fixed, and keys cycled.
- gameguy43 13y agoI think this error is fixed now. Thanks for the report! Let me know if you're still having trouble.
- Fede_V 13y agoThat was very useful, thanks. All pragmatic, useful advice and no generic bs. Edit: Annoying that you cannot try practice questions without logging in though.
- dkhenry 13y agoQuick someone show this to college students. Most of his advice is exactly what I am looking for when I give interviews.
- hermannj314 13y agoSo then give it to the people you are interviewing before you interview them. You don't need a middle man.
- buildit 13y agoNice site, could not do the practise questions though since I am not member of any of the social sites needed. Suggeting the option to proceed without the saving feature.
- bastiaanus 13y agoI am at the "write a function that reverses a string without creating a new string" question and this is the answer on the site: def reverse(str): left_ptr = 0 right_ptr = len(str) - 1 middle = len(str) / 2 while left_ptr <= middle: # swap temp = str[left_ptr] str[left_ptr] = str[right_ptr] str[right_ptr]= temp wouldn't this create an infinite loop? You're never incrementing / decrementing left_ptr or right_ptr.
- beat 13y agoI see that and want to do it by appending backwards off the end of the string, then move the pointer to the new beginning. Is that "creating a new string"? Or just making a poopy on the floor for the garbage collector? "Double the length of the old string and then cut it in half" isn't against the rules, right?
- bastiaanus 13y agoI don't know if it is against the rules, my approach was a recursive function.
- deleted 13y ago[deleted]
- beat 13y agoWell, yeah. That's the expected way to do it. My way has the benefit of bending the rule without breaking it. After all, we weren't told to not allocate memory, we were told to not create another string.
- deleted 13y ago[deleted]
- btilly 13y agoYup.
- 13y ago
- umsm 13y agoThe key point from the article: Communicate well. This is really very true in the corporate world. The better you know how to communicate, the more likely it is that you will succeed in your chosen profession.
- beat 13y agoAs an interviewer, I'm far more interested in soft skills than hard skills. I just want to know that they can actually program, which I can usually tell by how they talk about accomplishments in the face of some probing detail questions. Good programmers want to take a difficult problem, shoot it, mount its head on the wall like a set of antlers, and brag about it to anyone who will tolerate that. So competence shines through without a lot of tech question grilling. Soft skills, on the other hand... is this person an asshole? Inflexible and dogmatic? Timid? Boring? That stuff drags down a whole team.
- FLUX-YOU 13y ago>Timid? Boring? That stuff drags down a whole team. The previous 3 I get, but these two? Maybe we should be interviewing for the ability to get work done without being affected by other people?
- beat 13y agoTimid people get overrun by dominant people, and the kind of aspie cluelessness that runs through so many programmers (and I have no problem with that). So timid programmers often wind up unhappy and unwilling to talk about being unhappy, and the value of their ideas and opinions is lost. That's a loss to the team. Boring people? Hell, I just don't want to work with them. If I have a say in hiring someone I'm going to spend hours a day around, I'm going to do my best to make sure it's someone I find entertaining.
- deleted 13y ago[deleted]
- joyeuse6701 13y agoI've seen this first hand exactly as you've described... timid being overrun by the dominant and the not so socially introspective programmer.
- moonchrome 13y agoIf we met for the first time and you were in an authoritative position (interviewer) I'd probably come off as timid because I'm reserved around new people, but once I get to know the person/environment and get a good sense of my limits/role/status I have no problem voicing opinions or dealing with assertive people. Just because I might seem timid initially doesn't mean I'm a pushover, and I don't think I'm the only one like this.
- zachmokahn 13y agoThis is aweasome
- triplesec 13y agoThis reads even better as a "how to be a more insightful and incisive thinker and presenter", and anyone who just wants to use this excellent advice for interviews is missing the point!
- loblawslawblog 13y agoAlso found this book helpful for more practice questions & solutions: http://interviewsolutionsmanual.com/ http://interviewsolutionsmanual.com/
- obituary_latte 13y ago-1 for forcing sign in. What if I don't care about saving my progress? What if I'm not a member of any of those services? Answer: 10 second pageview guaranteed to not become a return visiter.
- HeyItsJames 13y agoThey have a list of all the questions you can go through, no sign in required. Not sure what you're talking about. http://www.interviewcake.com/all-questions http://www.interviewcake.com/all-questions
- obituary_latte 13y agoThat's great. Now, go to their homepage without being logged in and see if you can find a link anywhere to the all-questions page.
- binarycrusader 13y agoOnly by using "view source": <!-- <li> <a href="/all-questions">All Questions</a> </li> --> Note that they've commented out the link for some reason.
- obituary_latte 13y agoHrm. Maybe that's one of the interview questions.
- itsybitsycoder 13y agoHe's talking about the normal flow of the site (click the big blue button at the bottom of the first page, then the second page). This leads to a "Login with Github/Google/Facebook" prompt that can't be skipped. You can close it, but that doesn't get you anywhere.
- Splendor 13y agoI would guess that obituary_latte is talking about the fact that there's no link to the page you're referring to.
- kabdib 13y agoI had an interesting question once: They gave me a whiteboard problem that I'd studied about a week ago. So I told them. "Look, I did this problem on my own a little while ago." They chuckled and made it harder, which was fine. :-)
- bcjordan 13y agoThat's definitely the way to go. If you try to "remember" an answer you read or even previously completed while in an interview there's a good chance you won't instantly recall the answer and often the problem is slightly adjusted from your first encounter. It makes it difficult to see the problem with new eyes http://lesswrong.com/lw/k7/original_seeing/ http://lesswrong.com/lw/k7/original_seeing/ There are some serious benefits to bringing up your prior exposure to a question in a positive light. When sending out problems interviewees are likely to encounter again I include the group's "déjà vu guide" http://codingforinterviews.com/seen-question-before http://codingforinterviews.com/seen-question-before
- Jemaclus 13y agoHere's where I think I diverge from most people on this topic. My personal view is that I think by the time you bring someone in for an interview, you should already know that they can code, whether that's through code samples they provide or through Github accounts or whatever. TL;DR; Don't waste your applicants time or your own ## The Interview Interviewing should have two parts, imo: * Confirming that I actually wrote the code I sent you and know what it means * Confirming that you want to sit next to me for the next six months I can tell you right now that if I take time off my current job to go sit in your office for an interview and you ask me basic questions like "What is MVC?" or "What's the difference between a POST and a GET request?", I'm going to thank you for your time and walk right out. Why? Because my Github profile, which is featured prominently on my resume, contains examples of both. Half my projects are MVC projects, and many of them use 3rd party APIs (or are even APIs themselves!). The fact that you're asking me basic definitions means you didn't even pay attention to the stuff I sent you, so you're wasting my time and yours. You could have already figured this out ahead of time. Instead, you asked me to take time out of my day (probably during work hours) to ask questions whose answers I've already provided. (Please note that this only really goes for non-entry-level positions. For entry-level applicants, such as kids fresh out of college, you may not have very many code samples to work with. That's fine. In that case, send some problems for them to work on at home. Hopefully, these are dumbed-down but real-world problems your company has faced in the past.) ## Phone Screen (aka verifying authenticity) The first thing you should do is take a gander at my Github profile or my code samples. Then you call me up at a prearranged time and ask me questions about that code. Make me prove that I wrote what I said I wrote. * I noticed you made this combat simulator (www.bitfalls.com/2013/08/autofight-php-job-interview-task-part-1.html). Walk me through your thought process. * Your code appears to be a custom MVC. Why did you choose to go with a custom one versus say, CodeIgniter or Symfony? * This project is an API for Nerd Nite scheduling. First of all, what's Nerd Nite and why did you make an API for it? Second, explain how you scraped the data, organized it, and output the results. The above three questions will give you way more insight into my programming style and thought process than "What is an MVC?". Please. Don't waste my time. As a senior engineer with 7+ years in the field, I shouldn't need to prove the equivalent of my ABCs to you. It should be understood. I personally would also skip the whole "live coding" thing via Stypi or whatever. Waste of time, imo. You've already got code samples and you can ask me as many questions as you want about it. I shouldn't need to write code in front of you to establish my credentials. ## What about people who lie? There are people who lie about their resume and their qualifications, but that's exactly why you should tailor your questions to fit the code samples provided. If I don't get excited about that code and I can't eloquently explain why I did what I did or how it works, then maybe I didn't write it after all. It also gives you an insight as to my personality: I clearly took time out of my day to write this code. Why? What prompted me to write an API for Nerd Nite schedules? The answers to those questions should give you an idea of whether I can actually program or not. Questions like "What is MVC?" can be looked up in a dictionary. Explaining code samples is much more difficult. ## What next? Once you've established that I wrote the code I said I wrote, then Step 1 of The Interviewing process is mostly done. Now you bring me into the office to determine Step 2 -- am I someone you want sitting next to you for 8+ hours a day for the next six months? Do I fit in with company culture? You could give me a problem to solve on the spot, but hopefully it's more of a higher level thing rather than a "write code on a whiteboard" thing. The reason I say this is because at this point you should already have seen my code. You should know by now that I can build a class. The question you need to answer now is: given an arbitrary problem, can I solve it or at least come up with a reasonable thought process? Bonus points if it's relevant to the job. (i.e., if your job never requires you to write binary trees from scratch, don't ask the applicant to do so.) ## Finally Between the phone screen (technical) and in-person interview (personal), you should have a good idea of whether you want me on your team or not. Occasionally for small teams, you may decide that you need to know something about time, creativity, independence, and other similar qualities that you can't really get from code samples. If this is the case, then I suggest doing the contract thing, where you give them an assignment on contract. Once the assignment is finished, you hire them or pay them for the work completed (or hopefully both). I really, really, really despise whiteboard coding. I don't think it's indicative of anything, and I think you will find a lot of false negatives (i.e., rule out good candidates) using the whiteboard method. A few other thoughts: * I should meet my potential future boss at the in-person interview * I should meet at least one of my potential future coworkers * Be respectful of my time. Most interviews take place during work hours, so I've taken time off work -- and probably lied to my boss about where I'm going! -- to meet with you. The least you can do is not waste my time. * Be familiar with my resume and code samples. I took the time to write them, you should take the time to read them. It will answer way more questions about my abilities than a 20 minute quiz on technical terms will. The more informal the in-person interview is, the better. The technical qualifications should already be accepted by the time I walk in the door. At this point, it's a two way street as we figure out whether we want to work together. I'm interviewing you just as much as you are interviewing me. (Note: These are just my opinions about how I interview others. It hasn't failed me yet. On the other hand, almost every job I've ever interviewed for has completely wasted my time on that front.)
- known 13y agoquiz != interview
- RogerL 13y agoI think the programming/algorithms questions are probamatic. They by and large depend on seeing some trick. Take the array 1..n one. It's an 'aha' type question. You either see the trick, or not. I saw it after a minute, but rolled my eyes. How does that in any way predict whether I can solve hard problems in production. I give myself pretty high probability of not having that 'aha' moment in an interview; whether I did or did not tells you nothing useful. Not to mention that this is not exactly an obscure trick. If you've seen it a few times it is trivial to remember the trick and apply it. It's been awhile since I've looked at the 'interview questions exposed' type books or websites, so it didn't leap immediately to mind. Would you really select against me because I haven't read such things? edit: my phrasing was way to strong and unfriendly. I reworded the first sentence.
- typpo 13y agoI agree that the summation solution is an "aha" moment. But I don't think a reasonable interviewer would require someone to get that answer, and I can see how this problem could showcase a candidate's thought process and ability to reach incremental solutions. For example, a naive approach is to sort and find the element where arr[n] == arr[n+1]. From here, the interviewer can see if the candidate is aware that most sorts are O(nlogn). A better candidate knows that with a fixed range, you can sort in O(n). Maybe the candidate will go with a hash table or set and check for the duplicate that way. I've interviewed people who look good on paper but don't intuitively grasp how to use hash tables, so this is a useful screening exercise. My point is not that this question isn't simple, it's just that there are a number of ways to approach it besides the "aha" moment that give you insight into how a candidate works.
- RogerL 13y agoI see what you are saying. I was initially thinking about using dynamic programming, and surely I could illustrate my chops (or not) in that regard. But what if I do have that 'aha' moment, or I just remember that trick? Now you are not measuring my ability to think about these things on my feet, but either get no info (if I just regurgitate the answer), or get to evaluate my acting skills if I decide to pretend to 'figure it out'. And still, none of those, whichever way it goes, really answer how I do in production. I have come across plenty of really 'puzzle' clever people that cannot really pull together working code for a complex problem, and those (like me) who are just terrible at them, but really deliver (ignore that I'm patting myself on the back here, that's not the point, it's just a data point I know well). For example, I am terrible at chess. I'll move a piece into a lane where they can be attacked with impunity. The same goes with computers. Plenty of times I'll miss something obvious, for a short time (like the length of an interview). But I compensate for that with things like unit tests, thinking in the shower and then coding at work, and so on. Take it on faith that it works and I produce. For example, let's say I need to hire somebody to do a lot of low level optimizations. I can ask them some specific problem, and keep saying 'make it faster'. Or, I could start talking to them about cache misses, and see if we can just talk about it. Anyone that can actually do the work will be bringing up the pipelines, out of order instruction executions, the costs of going off chip, how to organize data and programs to minimize cache misses, well, the whole ball of wax. In that context I can start feeling out if they are original thinkers, or just plodding followers of some rules they read on HN or somewhere. If they don't have experience in this, but I think they might be good at it, I can talk about their debugging skills, or some other engineering/optimization problem that they have solved. I'll admit that this all presupposes an existing career - I do find it harder to interview and evaluate recent grads because it is all speculation at that point. Heck, if all you have done is CRUD apps I can see if you have thought about the good/clean code vs put it together to get it out the door to get market share issues. There is no one, clear, obvious answer, and a good mind will see that, and be able to free associate about it. A mediocre mind will repeat whatever HN quote resonated with them when they read it. If you can think about that clearly, you can learn the micro-architecture and then use the same style of thinking to optimize code. So, all of that is why I don't like 'aha' questions, or even reverse the string questions. I don't think it has any predictive value. Certainly, Google, which asks tough algorithmic questions, admits that with all their collected data they see no correlation between interviews and performance, except for the situational type interview stuff I write about (and that the OP wrote about).
- bcbrown 13y ago> Leave yourself plenty of room. You may need to add code or notes in between lines later. Start at the top of the board and leave a blank line between each line. That's a good idea I'll adopt. It looks messy when you start trying to shoehorn in a missed line somewhere.
- smtddr 13y agoThis is why I wish all programming interviews would just put me in-front of an Ubuntu machine and let me start up vim. Also, someone should develop a vim & emacs clone with super big font so it'd be good on a big-screen for coding-interviews.
- johncoltrane 13y agoYou can change the font size.
- ChikkaChiChi 13y agoAny time I've been a part of hiring new talent, I'm looking at three things: 1. How you process information. I'm not going to be impressed if someone at the table says 'Microsoft' and you cringe. 2. Can you admit to not knowing everything? You'd be shocked how big of an issue this is. 3. Are you willing to adapt? In a smaller team, you have to bend and be willing to take on new challenges.
- dancecodes 13y agoI think if you offer to code in interview its not right and dont resume good Man and company lost cool thinking programmer. In root its going from escape from peoples - such company not need with anybody. They must offer not coding, the must offer work and good things. Programming solve not coding it solve to make effective and easy. Coding in interview is monkey fun.
- yeukhon 13y agoPlease allow googling in an interview. How many people today actually write code without a Google search? I bet 90% of the Google engineers do that and still able to write really brilliant code.
- billnguyen 13y agoLove this! Was in a coding interview once where they just gave you a problem and you were given laptop and time to code out a solution using whatever you would normally use ie stack overflow. First interview I've had where I felt like it was a fair test of my programming capabilities. Of course this requires that you design the question in a way that is not completely google-able, but real world programming is not just about solving a trick question but being able to be resourceful enough to find a real working solution.
- yeukhon 13y agoI guess I should say restricted gooling. I like take home interviews. It's harder because you are given more time and more personal space and psychology tells us we will try to design the best algorithm, the most scalable, yet complex solution. If I were to conduct such interview, such solution can be a red flag. But you know, interview is hard. I also think interview questions don't have to change a lot. I heard Box always asks people to design an evaluator. I thought that wasn't so hard but when I started thinking about an evaluator, I started getting distracted by all the cases, even when I wanted to just implement a state diagram.
- kevinpet 13y agoDoesn't look like there's a whole lot of coding in that coding interview. Apparently the article assumes that "coding interview" involves a whiteboard, rather than a keyboard. We segment our interviewing into different sections. One person will do a specific functional competency evaluation which consists of writing code in an IDE to see whether you can write code. This portion of the interview is not about analytical thinking skills, people skills, or "tell me about a problem you've solved". It's about writing code. The interviewer is looking to see how many hints you need to get at working code, how well your solution is structured, and getting an overall feel for how you program.
- aidos 13y agoI'm just glad I work in python mostly and no longer have to deal with off by one errors...
- yixizhang 13y agoNice article, but not that good site design. Not to mention the solutions for most of its problem are either flawed or fundamentally not correct. Author of the site wrote solutions in Python, but obviously he/she doesn't understand Python. Isn't that against what the article suggested?
- Pirate-of-SV 13y agoFor http://www.interviewcake.com/question/largest-stack http://www.interviewcake.com/question/largest-stack There's a simple solution that requires no additional space. Disclaimer: Code is not tested or given the love it deserves. Class Item(): def __init__(value): self.value = value self.next = None self.next_largest = None Class maxStack(): def __init__(): self.top = None self.largest = None def push(value): i = Item(value) i.next = self.top self.top = i if value >= self.largest: i.next_largest = self.largest self.largest = i def pop(): v = self.top.value if self.largest == self.top: self.largest = self.largest.next_largest self.top = self.top.next return v def getLargest(): return self.largest
- anonymoushn 13y agoThis solution takes O(n) additional space...
- sgustard 13y agoAs the last round of a 3-hour interview I met the engineering manager whose first question was, "Do you know Perl?" and I said no and he said "Sorry, we need someone who knows Perl" and sent me home. After 3 hours of wasting my time! Not naming names, but Screw you and burn in hell for eternity SAP!
- shawiz 13y agoCongrats!