TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

I failed a Twitter interview

60 点作者 mostelato超过 11 年前

31 条评论

acchow超过 11 年前
This question involves an &quot;a-ha&quot; moment (for the linear-time solution) and was thus banned from interviews at Google last year.<p>Don&#x27;t use questions involving eureka moments. They reveal nothing about the candidate.<p>Edit: It should be noted that this question was used for a long time at Google, Microsoft, and many other places. It&#x27;s a terrible question.
评论 #6640130 未加载
评论 #6640065 未加载
评论 #6643047 未加载
评论 #6640076 未加载
DigitalSea超过 11 年前
No offence to Twitter, but this is a seriously bad way of hiring developers. What are you trying to recruit mathematics scholars as developers? When will companies like Twitter learn not all great developers are math geniuses? I didn&#x27;t even get a college education to get where I am, I failed maths in school as well, but I can code, so what does that mean? I think it means nothing in the greater scheme of things. By the sounds of it the author got a better position in the end, I&#x27;d rather be working at Amazon who are solving much better problems than Twitter ever will likely solve anyway.<p>If a company (no matter how great they were) tried asking me these kinds of questions, I would immediately stop the interview and thank them for the opportunity.
评论 #6640126 未加载
评论 #6640169 未加载
评论 #6640136 未加载
评论 #6640097 未加载
评论 #6640613 未加载
johnchristopher超过 11 年前
Google cache: <a href="http://webcache.googleusercontent.com/search?client=ubuntu&amp;channel=fs&amp;q=cache%3Ahttp%3A%2F%2Fqandwhat.apps.runkite.com%2Fi-failed-a-twitter-interview%2F&amp;ie=utf-8&amp;oe=utf-8" rel="nofollow">http:&#x2F;&#x2F;webcache.googleusercontent.com&#x2F;search?client=ubuntu&amp;c...</a><p>It&#x27;s off-line for me and asking something about installing a server.
评论 #6640415 未加载
评论 #6640116 未加载
评论 #6640141 未加载
评论 #6640068 未加载
huhtenberg超过 11 年前
&gt; <i>The next day I showed this question to my TA, who&#x27;s a PhD student in theoretical computer science. After 40 minutes he was also stuck with nothing.</i><p>That just doesn&#x27;t speak well of this particular PhD. The one-pass solution is rather obvious. I hate puzzle-based interviews with passion, but this is actually a very reasonable question and it does help to tell apart people with &quot;theoretical&quot; computer science skills from those with a bit more practical experience.
评论 #6640137 未加载
评论 #6643363 未加载
评论 #6643863 未加载
评论 #6640144 未加载
评论 #6640143 未加载
评论 #6640142 未加载
评论 #6640140 未加载
djhworld超过 11 年前
I had two phone screenings with Amazon recently and they decided not to continue with my application.<p>It was depressing to me and I felt down for quite a bit, mainly because on the second phone screening I just couldn&#x27;t do the coding task asked. My mind went blank and I probably sounded like a 5 year old struggling through the simplest of questions.<p>It&#x27;s my own fault though, I just got more and more stressed over the preceding weeks reading algorithms textbooks and &quot;CareerCup&quot; tests I think I just burned out.<p>I totally understand that top companies like Amazon and Google can afford to be ruthless and choosy in their interview process, after all, they&#x27;re top companies for a reason, but I guess it just wasn&#x27;t for me
评论 #6640188 未加载
评论 #6640805 未加载
pjan超过 11 年前
I really don&#x27;t get these coding interviews.<p>I can&#x27;t imagine a construction engineering company asking their applicants to do a construction calculation in an interview, and in this case, bad design can actually kill people (as opposed to a bug at twitter).<p>What else does it bring apart from some amusement to the interviewer?
noelwelsh超过 11 年前
Twitter failed you with that interview. Unless the job actually does involve performing computational parlour tricks.
评论 #6645161 未加载
softbuilder超过 11 年前
It&#x27;s not you, it&#x27;s them. A rather brilliant acquaintance of mine did the whole fly-to-SF song and dance with them and didn&#x27;t make the cut either. (He got snagged by a wonderful startup soon after though.)<p>What is important to understand here is that these processes are highly variable and there is an element of luck involved. It&#x27;s just the nature of a human-driven process and a complicated organization.
antirez超过 11 年前
I did not read the final solution but this was a little stimulating quiz, so this is my Ruby solution:<p><a href="https://gist.github.com/antirez/7231559" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;antirez&#x2F;7231559</a>
评论 #6640304 未加载
jjacobson超过 11 年前
So glad Twitter is continuing the tradition of useless interview questions.
susi22超过 11 年前
FYI this algorithm is called the &quot;Water filling algorithm&quot; and is used extensively in Communications to optimize the allocation power for channels.<p>You can get a solution with simple Lagrangian method (which I believe is the linear solution).<p><a href="http://www.eecs.berkeley.edu/~dtse/Chapters_PDF/Fundamentals_Wireless_Communication_chapter5.pdf" rel="nofollow">http:&#x2F;&#x2F;www.eecs.berkeley.edu&#x2F;~dtse&#x2F;Chapters_PDF&#x2F;Fundamentals...</a><p>(pages 183 - 185)
curiousDog超过 11 年前
Did they actually call you back with a rejection? Sorry if I missed that in the article. Anyway, at the end of the day, what matters is that you solved it on your own :)
评论 #6640099 未加载
JavascriptMan超过 11 年前
This pseudo-code seems to be with only one pass no ? Can someone find a counter-example ?<p><pre><code> overall_max=0 index_of_overall_max=0 Second_max=0 index_of_second_max=0 Array_of_cumulated_Sum=0 Total=0 for i from left to right if Height(i)&gt;overall_max &#x2F;&#x2F;Water Area between new max and old max Total+=overall_max*(i-index_of_overall_max+1)-(Array_of_cumulated_Sum(i)-Array_of_cumulated_Sum(index_of_overall_max)) overall_max=Height(i); index_of_overall_max=i; Second_max=0; index_second_max=i+1; else if Height(i)&gt;Second_max &#x2F;&#x2F;All the parts on second max is only to not miss the kept water at the end between the overall_max and another local max Second_max=Height(i); index_second_max=i end end if Array_of_cumulated_Sum(i)=Array_of_cumulated_Sum(i-1)+Height(i) end for &#x2F;&#x2F;At the end : water area between second max and overall max Total += Second_max*(index_of_second_max-index_of_overall_max+1)-(Array_of_cumulated_Sum(index_of_second_max)-Array_of_cumulated_Sum(index_of_overall_max)) return Total</code></pre>
seg超过 11 年前
Cheer up, kid. That Justin probably didn&#x27;t even know what you were talking about. Calculus is not for everybody. :-j
tiagobraw超过 11 年前
Once I failed at a google interview... I got 2 answers right but I couldn&#x27;t answer a third math related question (because the time was over).<p>The recruiter asked me what was the maximum number of edges on a graph without cycles.<p>When I was on my way home (in a bus) I had this &quot;a-ha&quot; moment.<p>Well, they lost a great computer scientist in their team! :P
granttimmerman超过 11 年前
I have my phone interview with Twitter next week.<p>I remember last year I got a similar question from both Twitter and Fb. It&#x27;s really just a buckshot. Sometimes you&#x27;ll get a problem that comes easy and sometimes you&#x27;ll be sitting there dumbstruck.<p>Best of luck with your future interviews.
etler超过 11 年前
I think this is a terrible way to conduct a phone interview. I think about code visually, and this is a very visual question, so thinking about this entirely in my head is way harder than writing it down. I&#x27;d be worried that having a computer in front of me would give the wrong impression, if typing sounds are heard on the phone, and I wouldn&#x27;t want to discount a potential great developer just because they were too nervous to ask if it were ok to grab a pen and paper. With all the ways we can communicate now, it seems archaic to ask someone to think through and explain their code over the phone.
评论 #6644720 未加载
iliaznk超过 11 年前
I wonder if Jack Dorsey could solve rhat right.
dhruvarora超过 11 年前
Wait. I fail to understand why this counts as a reason for rejection. You attempted a solution, which the interviewer backed up (I assume if you were heading in a completely incorrect direction, he would have told you that), you showed quick thinking (connecting local maximas to the problem) as well as coding competence and basic testing knowledge.<p>Is this not what Twitter desires through its interviews?Because time and again I have heard that companies look and focus on people&#x27;s thought processes more than their exact results.<p>PS: I&#x27;m a college student so I&#x27;m really keen to know how important being 100% accurate is.
isb超过 11 年前
Algorithmic interview questions should ideally have multiple solutions of varying complexity. The &quot;brute force&quot; solution should be obvious to anyone competent enough. If they are able to code it up with reasonable clarity and test cases, that is a good start (think of it as the fizzbuzz level). Good candidates should be able to get to the &quot;ideal&#x2F;aha&quot; solution with some hints. In fact, that process reveals a lot about the candidate. If the candidate doesn&#x27;t &quot;get&quot; to the ideal solution on their own, it shouldn&#x27;t be held against them IMO.
muxxa超过 11 年前
For a single pass from left to right, I think you need to maintain a counter for each y-value:<p><a href="http://codepad.org/W16O9vUB" rel="nofollow">http:&#x2F;&#x2F;codepad.org&#x2F;W16O9vUB</a><p>I actually think this is a good interview question, as playing devils&#x27; advocate and coming up with testcases that will break your initial code is a key programming skill, rather than assuming it is done and moving along.
isb超过 11 年前
In interviews and in general, it usually is a good idea to get a correct yet inefficient solution and then try to optimize it. This usually yields better insights in my experience. Here is a quadratic solution:<p><a href="https://gist.github.com/isbo/7239007" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;isbo&#x2F;7239007</a>
pencilcheck超过 11 年前
I have coded up one pass solution in ruby, check it out!<p><a href="https://gist.github.com/pencilcheck/7252934" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;pencilcheck&#x2F;7252934</a><p>A lot of solutions here doesn’t seem to take account of multiple puddles, my solution does take that into account.
twiceaday超过 11 年前
Here is a novel solution.<p><pre><code> make stack water = 0 for n in columns while stack not empty and n &gt; stack top water += min(stack bottom, n) - stack top pop stack stack push n</code></pre>
bartkappenburg超过 11 年前
This is a really nice and elegant solution: <a href="https://gist.github.com/orukusaki/bb189d9f69ad09e2cd5a" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;orukusaki&#x2F;bb189d9f69ad09e2cd5a</a>
paugay超过 11 年前
Here is my solution in PHP: <a href="https://gist.github.com/paugay/7262417" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;paugay&#x2F;7262417</a>
Joister超过 11 年前
Here&#x27;s my attempt, in java.<p><a href="https://gist.github.com/Joist/7229807" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;Joist&#x2F;7229807</a>
xentronium超过 11 年前
How will this solution work for cases like [1,2,1], when there will be no water held?
评论 #6640684 未加载
igor47超过 11 年前
you could solve this with a simple state machine; there&#x27;s no reason to resort to parlour tricks...<p><a href="https://gist.github.com/igor47/7228586" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;igor47&#x2F;7228586</a>
评论 #6640105 未加载
评论 #6640084 未加载
评论 #6640085 未加载
huangc10超过 11 年前
imo, interesting and fun question. Difficult to solve on the spot but not bad when you dive into it with a cup of coffee. Always just keep it simple.
stefan_kendall超过 11 年前
This is an extremely common ACM question. This would heavily bias toward anyone who has competed in the ACM, which is probably the worst metric for hiring ever.