
Show HN: Coding Interview Practice - gameguy43
https://www.interviewcake.com
======
RA_Fisher
I 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.

~~~
joe_the_user
Absolutely,

Interview questions should hinge on, like, the experience and competence that
I already have from having worked a substantial period of time as a
professional computer programmer. Not on how cleverly I do on BS.

And I actually generally do very well on this crap but I still hate being
impelled to take part in this kind of circus. In fact, it's annoying that I
jump to being a top candidate based on this stuff and only then does an
employer come up with some mundane requirement that should have been the
initial qualifier/disqualifier.

~~~
02
It is amazing to me to see computer science fundamentals hand-waved away as
'crap' and 'BS'.

~~~
Delmania
I don't think anyone would claim these things are crap or BS, I think it's
that these silly problem are irrelevant. These questions are like high school
or college coursework, artificial questions designed to reinforce the
instruction, but not something that would be encountered in a business
setting. Additionally, they tend to gloss over a person's experience. I may
not be able to solve your silly little stock trading problem by myself in a
short amount of time, but I am sure that within the normal development
environment, I could, especially since I would be working with a team. Or
could I? Since this question doesn't look into my ability to communicate or
work within a team, you don't know. Also, while I may not be able to solve the
problem in 45 minutes, maybe I should talk about the time I dove into an
application written in a foreign technology and managed to solve a critical
production bug before it could cost the company millions of dollar. But again,
you don't know that because you're obsessed with my ability to solve a high
school computer science problem. Different jobs require different skills.
Having the ability to code is important, but not nearly as important as
teamwork, communication, and the willingness to learn something new. That's
the problem with these questions, they are nothing more than smoke screen.

------
vladimirralev
It's getting a bit ridiculous how much effort and talent is now dedicated to
preparing candidates for interviews.

~~~
peachepe
I'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 : )

~~~
robotron
Look beyond SF.

~~~
peachepe
That is the plan :)

Im in LA right now and will check other places.

------
jasonhanley
This 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.

~~~
jarjoura
It 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
'Culture fit' \-- the wild card that lets you reject any candidate.

~~~
mbillie1
A nebulous description of a vitally important quality - someone who your
existing team won't hate. It's one-sided to claim that people only use it to
unfairly reject candidates. Being an a __hole is something I 'd like to see
candidates rejected for, but it won't show up in a technical assessment.

~~~
frostmatthew
> Being an ahole is something I'd like to see candidates rejected for, but it
> won't show up in a technical assessment.

I'm not sure that shows up in hours of interviews either...especially when
most (all?) of that time is spent on "technical assessment"

~~~
02
It filters out the people whose ego won't let them take the test.

~~~
krainboltgreene
And people who don't think tests are a good start to a relationship between an
employee and a company.

And people who are getting better offers at better companies.

You'll never know.

------
stygiansonic
A 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.

~~~
gt384u
I 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.

~~~
stygiansonic
I don't have a problem with a vague question and in fact a candidate asking
clarifying questions is indeed a Good Thing.

However the way the question was phrased just makes it seem like the person
who phrased it doesn't understand how trading works in real markets.

------
li2
Alice 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.

~~~
smtddr
_> >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-3...](https://www.linkedin.com/today/post/article/20130620142512-35894743-on-
gpas-and-brain-teasers-new-insights-from-google-on-recruiting-and-hiring)

 _" 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.”_

------
sciguy77
The 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
But 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
I'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
Man, can I get your help writing sales copy? :P

------
anorark
[https://www.interviewcake.com/all-
questions](https://www.interviewcake.com/all-questions) (link is commented out
in the page source)

~~~
gameguy43
Yeah, 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
If 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.

~~~
blisterpeanuts
If 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
Reading 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.

------
elilux
Interviewcake.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.

------
debt
I 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.

------
incision
I 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/)

------
jimmaswell
Spoilers 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.

------
codezero
I 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
Say 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.

------
myblake
Looks 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).

------
dxbydt
This 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

~~~
NoodleIncident
I 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
I 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/cloju...](https://github.com/clojure/clojure/blob/master/src/clj/clojure/core/reducers.clj)

------
gameguy43
Love 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?

~~~
cpwright
I'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).

------
elyrly
Parker (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.

------
WoodenChair
Hey 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
Hey 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.

------
ipsin
The 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
What 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]).

~~~
chaoxu
I 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-o...](http://cstheory.stackexchange.com/questions/19591/avoiding-
overflow-in-finding-a-solution-toax-by-c)

~~~
jw2013
> 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)))

~~~
chaoxu
If we sum all the numbers we get n(n+1)/2 + x, where x is the duplicate
number. Assume n(n+1)/2 = a mod n.

If we did mod n addition the whole way, we have the result a+x mod n, and let
that number be b.

Claim: if a + x = b mod n, then there is a unique solution x in between 0 and
n-1. In fact x = (b - a) % n.

Now, if x = 0 from the above computation, you would know it is n instead of 0.

~~~
jw2013
But x is not necessarily smaller than n though. For example:

Duplicate array: [1,2,2,3,4]. If you do mod 2 sum, then you have 1+0+0+1+0 = 2
mod 0 = 0. But another possible duplicate set can be: [1,2,3,4,4].

10 + x = 0 mod 2 (see 4%2 = 0 and 2%2 = 0? So x can be either 2 or 4.) If you
let modulus number N be larger than n (e.g. n = 5 in my example, just let N =
6. Then 10 + x = 0 mod 6 will yield only one possible solution that is 2) then
I think your solution will definitely work.

But I think the big problem is: you said x = (b - a) % n. That is true, but
how do we get "a" (the sum of all unique numbers from 1 to n) without
overflowing? The reason we do modulus summation is for avoiding overflow,
granted that can get "b" easily, yet now we have to find "a" still, I find we
are still stuck. Any suggestion?

Even if assuming everything will work out and my previous question can be
responded, still the modulus function is WAY MORE expensive to compute than
xor operation.

~~~
chaoxu
> If you let modulus number N be larger than n (e.g. n = 5 in my example, just
> let N = 6. Then 10 + x = 0 mod 6 will yield only one possible solution that
> is 2) then I think your solution will definitely work.

That was entirely what I was suggesting, but we don't need N>n. N=n would
work. (btw, I defined n to be the size of the list -1, therefore in your
example, the number is 4)

> But I think the big problem is: you said x = (b - a) % n. That is true, but
> how do we get "a" (the sum of all unique numbers from 1 to n) without
> overflowing? The reason we do modulus summation is for avoiding overflow,
> granted that can get "b" easily, yet now we have to find "a" still, I find
> we are still stuck. Any suggestion?

We can compute a using the same function that computes b. just sum all numbers
from 1 to n mod n. Here is a quick demonstration in Haskell.

[http://lpaste.net/101868](http://lpaste.net/101868)

> Even if assuming everything will work out and my previous question can be
> responded, still the modulus function is WAY MORE expensive to compute than
> xor operation.

True. I just want to show how to modify another solution so there is no
overflow.

------
Zaheer
I 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/)

------
alashley
Subscriber 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
Hey 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-
expl...](http://stackoverflow.com/questions/487258/plain-english-explanation-
of-big-o/487278#487278)
[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-...](http://www.daveperrett.com/articles/2010/12/07/comp-sci-101-big-
o-notation/)

Best of luck!

------
pauleastlund
Good 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.

------
chrisfarms
The 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/)

------
thewillcole
Yes! I got the first question right. Somebody should hire me as a programmer.
:D

------
gameguy43
Sorry 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!

------
Pitarou
For 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
They mention it, actually.

------
danielweber
Holy cat snacks, this page uses a lot of third-party JavaScript.

~~~
jarjoura
I'm up-voting this just for your use of "Holy cat snacks," BWAHAHA.

------
VonKeebles
First question is wrong, I could have just sold short. ;)

------
wyclif
I 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.

------
Jach
I 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.)

------
suyash
Any one has a link to all the solutions? It's annoying to get to those via
hints all the time.

------
monkeynotes
Could use some syntax highlighting to make the code examples more easily read.

------
mondayRain
Wait, so just to clarify - there are only 14 questions?

------
huangc10
you know what would be great? having the answer in multiple languages :) just
an idea. good luck, nice site, I like it.

