6 ms·
Show HN: Coding Interview Practice
- thewillcole 13y agoYes! I got the first question right. Somebody should hire me as a programmer. :D
- myblake 13y agoLooks like the site has been improved considerably since I last checked it out, love the new content and context (especially the story about Alice in the about page).
- deleted 13y ago[deleted]
- VonKeebles 13y agoFirst question is wrong, I could have just sold short. ;)
- deleted 13y ago[deleted]
- pauleastlund 13y agoIf the max profit involves buying at X and selling at Y, X is always the minimum price that occurs before Y in the timeline.
- anorark 13y agohttps://www.interviewcake.com/all-questions https://www.interviewcake.com/all-questions (link is commented out in the page source)
- gameguy43 13y agoYeah, that page is there so people who have finished all questions can go back and review. You can basically get around the paywall using this link. I figure people who dig around to find a way around the paywall probably wouldn't have paid anyway :P
- akbiggs 13y agoIf I pay to get all the questions only to learn later that I could have accessed them all easily for free, I'm going to feel ripped off, even if it was only $5. Either make sure the questions are blocked off properly or let everyone have access to all of the questions. You can't have it both ways here.
- canadev 13y agoI don't see the sense in this response. Just because I can pirate something doesn't make me feel ripped off for not doing so. I feel better for having paid someone for their time and effort.
- deleted 13y ago[deleted]
- blisterpeanuts 13y agoIf I pay for this Pepsi only to learn later that I could have easily stuck it in my coat for free, I'm going to feel ripped off, even if it was only $1.25. Either make sure someone's watching me at all times and patting down my coat at the door properly, or let everyone have Pepsis for free. Doesn't seem quite as appropriate when the context is changed, does it?
- akbiggs 13y agoReading through this I see I was wrong. Thank you. My reaction was provoked when I was considering paying for the rest of the questions, saw the comments and saw the link to all of them. I was too hasty in my response.
- anorark 13y agoI was actually not trying to find my way around the paywall :) I didn't know you had to pay to access all 14 questions.
- suyash 13y agothanks @anorark!
- sciguy77 13y agoThe line, "this is not just another technical question database" is really effective. You anticipate the first possible criticism someone might have and dispel it. I'll definitely give this a whirl soon, great work.
- suyash 13y agoBut it kind of IS and the fact that the quality and quantity of questions is far inferior to some of the other books on interview prep I've looked at in the past.
- adambard 13y agoI'd say the step-by-step hint process is the secret sauce. It mimics an actual interview scenario (where a generous interviewer might be willing to help you along) while teaching by example some structured ways to break down the problem by walking through it step by step. Notably, most of the answers start with a brute-force solution and optimize from there, which (IMO) is an excellent way to approach these sorts of problems, especially in a stressful situation such as a real job interview.
- gameguy43 13y agoMan, can I get your help writing sales copy? :P
- elilux 13y agoInterviewcake.com is awesome. At TechCareerHQ, we buy all our student memberships because of the quality of the questions and ability of students to focus on one question at a time. After using Interviewcake, our students are much more prepared for interviews.
- codezero 13y agoI love this idea and the way the problems are presented. One suggestion (based on the one question I saw) is to also mention at least in passing, concerns with edge cases in the inputs. Python often lets you ignore these things but interviewers tend to be charmed by at least an attention to the possibility that your input is empty. Also, it might be worthwhile to have some "homework" problems that don't have solutions that are variations of the main problem. For example, the stock price problem is sometimes presented as changes in price rather than absolute price. This adds some subtle differences that might throw people off unless they've tried it. I imagine similar variations exist for all the problems available.
- xixixao 13y agoSay at Microsoft interviewers will drill you on edge cases (but it really is common in most shops). That means all empty / invalid input as well as overflow, floating point errors etc. Some places care about reliability vs speed or elegance more than others.
- stygiansonic 13y agoA bit of a nitpick, but the stock trading question should have stated up front that short-selling was not allowed or that the purchase order must precede the sell order. (I suspect someone with some familiarity with trading would have asked these questions in an actual interview for clarification) Relying on a "hint" to figure out that you can only sell after you buy seems more like an additional constraint rather than a true hint.
- deleted 13y ago[deleted]
- mehrdada 13y agoIndeed. Having had quite a bit of experience with ACM-type competitions, I believe it is super-important for technical coding questions not to leave room for misinterpretation (especially when the key point being tested relies on the accurate interpretation, like this case.) Being sloppy in the interview may lead a bad taste in the mouth of the best candidates, because they are the ones who will take the question most literally. It's not an excuse to leave things like that vague so that a candidate would have to bring it up to you. If you want to ask open-ended questions, ask obviously open-ended questions; don't make an attempt to turn simple technical questions into open-ended ones.
- stygiansonic 13y agoAgreed. I feel that if a question is going to be about a "real world" situation like trading stocks, it should reflect real world constraints that should be stated up front. I also found it curious that the example listed the stock price at 1 AM. It would be far more of a real world example to only consider times during the normal trading hours. A question phrased about a particular real-world domain that doesn't makes sense within that domain just doesn't seem fair to ask. But again, total nitpick on my part. The actual format in which the questions were presented was generally done well, and a nice refresh from the typical "interview prep" sites.
- gt384u 13y agoI feel like completely specifying the problem does everyone in an actual engineering interview a disservice and isn't a good analogue to actual engineering problem-solving. That said, it might be acceptable or even encouraged for the purposes of this site. In the case that you mention, if someone asked me "Can I short sell?" I'd be happy that they considered the order of events there and were trying to explore the problem. I'd certainly remember it in my interview feedback. My response as an interviewer would be more or less "That's an interesting thought. To simplify the problem, let's say we're risk averse and prefer a finite loss potential. Go ahead and just consider purchase before sale." One of the biggest criteria I looked for from junior engineering candidates was that they didn't just jump into implementation and asked clarifying questions. That's hard to do with the sort of site this is so maybe in this case more complete specification is useful, but any way that a bit of ambiguity can be introduced means that you can have a meaningful conversation with an engineer about representation, the shape of the problem, the inputs, what the criteria for success are, what is truly necessary to solve a problem. I want working code in the end, but hearing the things a person does or does not consider about a problem is interesting and valuable to understand a potential teammate and how they think.
- ipsin 13y agoThe problem involving a duplicate number from 1..n... The sum 1+2+...+n is just n(n+1)/2. Something worth knowing for this sort of "trick" problem.
- jw2013 13y agoWhat if the summing overflow? Why not just XOR all the numbers in the set with 1...n (assuming the question is there is only one duplicate in integers in range [1,n]).
- gameguy43 13y agoBoth great notes. Will workshop the question to include mention of constant-time ways to get the sum. Thanks!
- chaoxu 13y agoI feel what you asked is a really nice follow up question, as tricks to not get a overflow could be highly non-trivial. One can do addition mod n. As long as 2n doesn't overflow, you are good. You can further improve it by not using any number larger than n. Say we want to sum a+b mod n, wlog assume a<b. If a+b<=n, we are good. If not, then b>n-a. Note a+b mod n = a+(n-a)+(b-(n-a)) mod n = (b-(n-a)) mod n. Now the calculation doesn't overflow. Here is something to show avoid overflow can be quite difficult... http://cstheory.stackexchange.com/questions/19591/avoiding-overflow-in-finding-a-solution-toax-by-c http://cstheory.stackexchange.com/questions/19591/avoiding-o...
- jw2013 13y ago> One can do addition mod n. As long as 2n doesn't overflow, you are good. I wonder if the result will still be correct. It's possible to have multiple answers. e.g. (7 + 10) % 6 = 5. But both 5, 11, 17 % 5 == 5. Can you find which one is the actual sum though? ---btw, the xor solution--- (defn find-dup [dup_set test_set] (reduce #(. clojure.lang.Numbers xor %1 %2) (into dup_set test_set)))
- 13y ago
- li2 13y agoAlice got in facebook just attended coding boot camp and did some algorithm practices. Why does facebook recruit a non experienced like Alice but turns off lots of talented (with a top school cs degree)/with decent working experiences? I am curious.
- humannature 13y agowho is alice? so you're just bitter you got rejected by fb?
- smtddr 13y ago>>Why does facebook recruit a non experienced like Alice but turns off lots of talented (with a top school cs degree)/with decent working experiences? I don't know what you're considering "talented", but Google seems to believe that your school/GPA has almost nothing to do with how well you'll perform on the job. NOTE: Let's not confuse this with how likely you are to become another Zuckerberg. Starting a company is completely different from working at one. I don't think Zuckerberg could work at Google. He'd be bored out of his mind and/or argue with everyone, then quit in less than a year. https://www.linkedin.com/today/post/article/20130620142512-35894743-on-gpas-and-brain-teasers-new-insights-from-google-on-recruiting-and-hiring https://www.linkedin.com/today/post/article/20130620142512-3... "GPAs don’t predict anything about who is going to be a successful employee. “One of the things we’ve seen from all our data crunching is that G.P.A.’s are worthless as a criteria for hiring, and test scores are worthless — no correlation at all except for brand-new college grads, where there’s a slight correlation,” Bock said. “Google famously used to ask everyone for a transcript and G.P.A.’s and test scores, but we don’t anymore, unless you’re just a few years out of school. We found that they don’t predict anything. What’s interesting is the proportion of people without any college education at Google has increased over time as well. So we have teams where you have 14 percent of the team made up of people who’ve never gone to college.”
- monkeynotes 13y agoCould use some syntax highlighting to make the code examples more easily read.
- vladimirralev 13y agoIt's getting a bit ridiculous how much effort and talent is now dedicated to preparing candidates for interviews.
- elwell 13y agoDoesn't matter what the actual need is; the point is that there is lot of demand for people who want to prepare for interviews.
- 7Figures2Commas 13y agoIf only they knew that their newfound interviewing skills will in most cases land them...a job doing maintenance on a pedestrian CRUD app. It's a sad state of affairs when the most intellectually challenging part of your job is the coding test you had to pass to get it.
- _vn5r 13y agoI'm from Central America. I went to SF and had a few interviews over a month. I failed in all those 40-minutes-solve-as-many-as-possible-fizzbuzz-problems because I wasn't fast enough. That said, I've been working as a web developer for 11 years now, bulding CRM's, CMS', Crawlers, automation tools, and all kind of web based stuff companies needed. Also, I never went to college, and have been working before finishing high school (15 years old). So, while I lack a lot of computer science education, I consider myself competent at developing solutions, and have progressed with coding practices. But because of the US interviewing style, which I had never gone throug before, I am not employable there. Interview Cake may be just what I need : )
- suyash 13y agoAny one has a link to all the solutions? It's annoying to get to those via hints all the time.
- Zaheer 13y agoI used to have a site like this but only show one hint. Love the concept of having multiple levels of hints though! www.InterTechTion.com Edit: Link to archive of all questions I sent out: http://www.intertechtion.com/answers/ http://www.intertechtion.com/answers/
- gameguy43 13y agoSorry the site's a little slow guys. I'm up to 100 dynos on Heroku but things are still a bit sluggish at times. Looks like I need to move more stuff over to the CDN? Thanks for the load testing!
- pauleastlund 13y agoGood execution on a simple premise. Another terrific resource that I've pointed a lot of friends to is Project Euler -- a little heavy on the math but a lot of interesting questions that are great prep for the Google (or Facebook, or Twitter, etc.) gauntlet.
- elyrly 13y agoParker (creator) does a wonderful job of laying out the different techniques to preform well on technical interviews. The format is easily understood and flow of questions is gradual enough to traverse.
- incision 13y agoI like this a lot. Went ahead and signed up as some of what's there is probably bit over my head. Looking forward to seeing it grow. I'd love to see even more discussion on each solution. Ideally something like an interactive "The Practice of Programming" [0]. 0: http://www.amazon.com/dp/020161586X/ http://www.amazon.com/dp/020161586X/
- WoodenChair 13y agoHey gameguy43, Great site! Can you tell us about the tech you used to build it? I see Heroku... Is that Bootstrap too? What language/framework/database are you using? Thanks!
- gameguy43 13y agoHey there! Yep, bootstrap and angularjs in the front, Django in the back. Cloudfront CDN to handle the static assets (I've /really/ fallen in love with their product--so easy to set up). And of course, Stripe for payments.
- gameguy43 13y agoLove to get some thoughts from people on the pricing. Today the first 3 questions are free, and it's $5 for access to the other 11. How would people feel about $10? $20? What if there were 30 questions, sorted into different topics?
- mondayRain 13y agoI feel as though to top something like "Cracking the Coding Interview", you're going to have to get close to the breadth they cover for the price they charge. You mention they 'charge' $25 which for sure is more than your $5; however, they've got loads and loads of questions for each data structure. Currently, you're selling each question for about 35 cents. Although that's super cheap per question, $5 for 11 questions somehow doesn't seem like a great deal. However, I think people will be willing to pay the same for a larger database of questions e.g. I would be happy to pay $25 for 80 questions).
- kimagure 13y agoI paid the $5 because the sales pitch is so convincing -- "for the price of a burrito, you can get a job" (and so I did pay for this and I did get a new job!) edit: back when I used this in Feb, I constantly got logged out and had to log back (was using G+ logins). Did this get fixed?
- yblu 13y agoOnly 14 questions in total? And they cover "trees, graphs, depth-first search, greedy algorithms, brute force algorithms, dynamic programming, memoization, divide and conquer, amortized analysis, and more?"
- cpwright 13y agoI'd expect it to provide about the same value as a book, and be browseable; not something that is purely linear one after the other (e.g., I could skip to dynamic programming, graph algorithms, or whatever topics there happen to be). I think that a basic interview puzzle book should be in the range of $25-$40, and depending on that price point be from 150 to 300 pages, with roughly 50-100 problems. Though, admittedly, I wouldn't pay for this at the moment because I'm happily employed. I did spend about $100 on books to brush up when I was interviewing in late 2011. I found actually the best practice for interviewing was going on interviews (I ended up interviewing at around dozen companies over the span of a month after I was laid off).
- debt 13y agoI wonder if they'll eventually allow anyone to go to this site too be interviewed, live, by an actual engineer. For example, a prospect just shows up and jumps right into a technical interview with an interviewer from an interested company. It'd be good practice from the perspective of the engineer and act as potential job applicant from the perspective of the interviewer. Totally non-committal. I would imagine multiple prospects doing the interviews at the same time with the same interviewer. Instead of scheduling an interview, you have prospective companies posting their interview schedules. For instance, "Hi, I'm from Google. I'll be hosting a technical interview at 330 PST. If you'd like to potentially work for Google, go to this link and answer my question in the time allotted. I'll be in the room to answer any questions." Of course, there's no whiteboarding involved but it might act as a pretty decent vetting process.
- jasonhanley 13y agoThis is such a huge indication of the horribly sad state of interviewing and hiring programmers. The current process results in hiring people that are awesome at interview quiz questions, but can't sit down and do the actual day-to-day work.
- humannature 13y agosays the bitter guy who got rejected by google
- jarjoura 13y agoIt goes without saying that solving algorithm questions are only a part of the interview process. Candidates are also judged on culture fit and design skills.
- derwiki 13y ago'Culture fit' -- the wild card that lets you reject any candidate.
- JackMorgan 13y agoThe idea that culture fit is just a catch-all for personal bias and -ism's recently occurred to me, and kind of freaks me out. Right now I think there are three things I'm most looking for in a quality Sr candidate: restless learning, pair programs well with my team (we do it on all production code), and focuses on solutions not problems. I'm afraid though that "culture fit", especially around pair programming is just a way for me to cop out on someone I don't like, but I can't prove it.
- derwiki 13y agoIt's a slippery slope if you ask me. If you don't like them, you might not be able to work well with them. What's more unfair -- adding someone to the team who will cause problems because they're qualified -or- rejecting someone who is qualified because your 45 minute evaluation is, "they're not a good fit"? I don't know the answer. But I do know that it's a lot harder to fire a bad fit than to never hire them to begin with. I expect this to bite me as ageism in ten years, when a 23 y/o Stanford grad will be aghast that I don't spend my evenings playing with MeteorRails.js.
- chrisfarms 13y agoThe step by step expansion are really great, and I'm sure this will help many. I think I prefer the learning by doing approach like talentbuddy[1] personally. [1] http://www.talentbuddy.co/ http://www.talentbuddy.co/
- mondayRain 13y agoWait, so just to clarify - there are only 14 questions?
- jimmaswell 13y agoSpoilers in its URLs? I'm on the search engine one and the URL says "compress-url-list" I guess I was a bit off-base, I was thinking about using a database. Well cool, this trie thing it suggests is pretty much what I was thinking, and something I'd thought about before without knowing what it was called.
- danielweber 13y agoHoly cat snacks, this page uses a lot of third-party JavaScript.
- jarjoura 13y agoI'm up-voting this just for your use of "Holy cat snacks," BWAHAHA.
- wyclif 13y agoI haven't tried it yet, but will later tonight. I just dropped by to say that this is a great problem to solve. It addresses an emerging market.
- RA_Fisher 13y agoI have zero desire to play these silly games. Sorry, I'm much more than a 40 minute probability puzzle! The only way to win is stop playing. Give me a problem to take home, and think about. Or, how about asking me about my skills (and having a conversation about a piece of code). How about pair-programming? TDD abilities count for nothing, whaaaa? These types of tests do little more than reinforce stale ideas and turn away unconventional well-rounded candidates. Used to play the game, now I win because I don't play.
- RA_Fisher 13y agoLike one of their examples, "I have an array stockPricesYesterday where the keys are the number of minutes into the day (starting with midnight) and the values are the price of Apple stock at that time" My response would just be, "you generally shouldn't store data in keys". Their response, "Okay, just solve the problem." No real discussion.
- WoodenChair 13y agoI'd give you brownie points but still expect you to answer the question. These questions are not THAT hard - they are definitely fair game and help screen out the people who only know how to use APIs and not how to think about things at a lower level. But I agree an array would be a more efficient data structure for this :)
- RA_Fisher 13y agoAnother problem I have is that I get terrible anxiety in the interviews and my brain shuts down. I've made a personal decision for my own well-being not to participate in these types of interviews, no matter the circumstances. At that point, it's in the company's court. I will happily demonstrate in many ways that I've solved these problems and more complex problems before. Including narrating my code, papers, articles, body of work, speaking of my aspirations as a data scientist / developer. Talk about learning JavaScript from Crockford and what I've learned. Opinions on DHH's Agile v4 and convention over configuration. The truth is, I research every problem I have (at least a little bit). I never sit down and blindly program or do math problems. I'll never forget my former Bell Labs-theoretical statistican advisor (American. Stat Association decorated!) telling me about accidentally helping his high school-age daughter fail on a take-home probability problem for school.
- alashley 13y agoSubscriber here, I felt like I needed interview preparation to be able to go through this interview preparation. I think it would be helpful to list some resources for those less well-versed with these types of problems. Will you be adding more questions in the future? I do like the concept of the site!
- gameguy43 13y agoHey there, The problems are definitely a bit more advanced. I do try to make sure that any "vocab words" (data structures, algorithm types) can be clicked on for a deeper explanation. But if you haven't seen big-o before, for example, you'll be in the dark on a few things right now. I have some more "bottom-up" curriculum that I've developed from teaching at boot camps around San Francisco, and I'm still working on figuring out the best way to present it on the site. For Big-o specifically (the thing that looks like "O(n)"), I really like these resources: http://stackoverflow.com/questions/487258/plain-english-explanation-of-big-o/487278#487278 http://stackoverflow.com/questions/487258/plain-english-expl... http://www.perlmonks.org/?node_id=227909 http://www.perlmonks.org/?node_id=227909 http://www.daveperrett.com/articles/2010/12/07/comp-sci-101-big-o-notation/ http://www.daveperrett.com/articles/2010/12/07/comp-sci-101-... Best of luck!
- Pitarou 13y agoFor the indexing the web question (what data structure should an under-resourced web-crawler use to keep track of visited links?) wouldn't a Bloom filter work better than a trie?
- scotth 13y agoThey mention it, actually.
- Jach 13y agoI noticed on the 'Validate string with open/close is well formed' question an edge case that's not handled. If the input has a trailing closer char with an unmatched opener, an IndexError will be raised because the stack will be empty when you try to pop from it. (Unless your particular Stack class just returns None or something? But then you'll get a KeyError when trying to access that key in the dict.)
- huangc10 13y agoyou know what would be great? having the answer in multiple languages :) just an idea. good luck, nice site, I like it.
- dxbydt 13y agoThis is a very good list - I was asked a bunch of these & thankfully I was able to solve them & land the job. It's significantly harder to solve these if you require immutability (which they did in my case, since we work with Scala) For example, the stock price problem (https://www.interviewcake.com/question/stock-price https://www.interviewcake.com/question/stock-price ), if you insist the solution has no mutables, I really don't know how a Java/Python/C guy would approach it. In Scala, you'd do import math._ val s = List.fill[Int](100)((random*1000).toInt) s./:((s.head,0)){(a,b)=>(min(b,a._1),max(a._2,b-min(b,a._1)))}._2
- bcoates 13y agoCan't you always mechanically convert an iteration into a fold like that?
- NoodleIncident 13y agoI can't really understand your version, I'm not familiar with scala. Is this somewhat equivalent? I tried to use Clojure's loop/recur but I'm too much of a noob. :( def max_profit(stocks): def r(stocks, profit, lowest): return r(stocks[1:], max([profit, stocks[0] - lowest]), min([lowest, stocks[0]])) return r(stocks[1:], 0, stocks[0])
- dxbydt 13y agoI think so. You've basically reimplemented a fold, but clojure stdlib has a built-in left fold. See line 84 https://github.com/clojure/clojure/blob/master/src/clj/clojure/core/reducers.clj https://github.com/clojure/clojure/blob/master/src/clj/cloju...