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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Retiring a Great Interview Problem

173 点作者 dtunkelang将近 14 年前

18 条评论

georgemcbay将近 14 年前
Why retire the question just because you saw it on Glassdoor? The same question was posted to sureinterview last year, so anyone you hired since November is suspect! (If you believe that potential advance knowledge of the question is relevant).<p>Worse yet, even if you did come up with this problem on your own, this exact problem was a fairly common interview question back in the mid 90s, when string processing interview questions were all the rage for C/C++ programming jobs -- I must have seen it a dozen times in various interviews over the years. The problem is familiar enough that I'd bet a decent amount of money that it must be listed in one of those interview problem books that were popular before the websites for this stuff started showing up over the past couple years... If you really relied on the interviewee having no possible advance knowledge of this question prior to the interview you surely had a false sense of security prior to seeing it appear on glassdoor.<p>As long as you engage the interviewee to see that s/he really understands the answers they are giving, I don't really see why it matters if the question has appeared on one of these sites. If the interviewee is preparing for their interviews enough that they are actually looking at these sites and understanding the answers to the point where they can intelligently discuss them, that probably already puts them in the upper tier of people you'd want to seriously consider hiring, so retiring the question is probably counter-productive unless you have a non-disclosed alternative that you're sure is as good of a question.
patio11将近 14 年前
A spiritually similar question at a previous employer resulted in many candidates attempting to iterate over the dictionary rather than iterating over the string. We hired them. At least they could iterate over a dictionary. That's a surprisingly rare skill in the hiring pool.<p>Maybe I'm just getting cynical in my old age, but sometimes I think the world is awash in incompetence. We see so much of it in tech because our incompetencies are (marginally) harder to hide.
评论 #2859916 未加载
评论 #2860188 未加载
评论 #2859469 未加载
评论 #2859892 未加载
pbh将近 14 年前
I hope readers aren't getting the impression from this article that the code examples provided are the correct way to do word segmentation in English. (Though I understand this is an article about interviewing and not about word segmentation. And this might be considered a preprocessing step for doing things correctly...)<p>Norvig gives a very approachable version of English word segmentation that uses a language model below.<p><a href="http://norvig.com/ngrams/" rel="nofollow">http://norvig.com/ngrams/</a>
评论 #2864504 未加载
JL2010将近 14 年前
I had a similar question with a twist asked of me during an interview. It went something like this:<p>Given a list of all the short strings in the periodic table of elements (e.g. Na, F, Al, etc) and a list of all the words in the English language: 1) write a method that finds the longest possible English word you can spell given any combination of the strings in the periodic table of elements. Re-usage of elements in the same string are allowed. 2) Describe what kind of data types you would want for the two lists and describe anything special about them. 3) Give a big O estimation.<p>I thought it was a great question :)
tzs将近 14 年前
I would have thought of dynamic programming when asked if I could solve it more efficiently, but I've somehow just not had much occasion to use dynamic programming, so would have had to admit it would take an evening of reviewing my algorithms books to actually solve it that way.<p>However, I would have been able to come up with an alternative O(n^2) solution, involving building a directed graph with vertices representing each position in the string and the end of the string, with edges connecting two vertices if there is a dictionary word starting at the position corresponding to one vertex and ending just before the position corresponding to the second vertex. This can be done in O(n^2), and then you can find the shortest path from the vertex for 0 to the end vertex on this graph in O(n^2) (e.g., by Dijkstra's algorithm), and that gives you an exact covering of the string using the minimal number of dictionary words.
评论 #2859733 未加载
评论 #2860125 未加载
StavrosK将近 14 年前
Only slightly joking:<p><pre><code> re.findall("(your|dict|here)", "yourword") </code></pre> I like the idea of constructing a state machine to do all the matching.
评论 #2859800 未加载
评论 #2859914 未加载
评论 #2861909 未加载
评论 #2859811 未加载
评论 #2861871 未加载
nandemo将近 14 年前
Just for fun I decided to rewrite his first version in Haskell. This is probably not idiomatic, though.<p><pre><code> segment_string :: String -&#62; Set String -&#62; Maybe String segment_string [] _ = Nothing segment_string str dict = if str `member` dict then Just str else let pairs = zip (inits str) (tails str) pairInDict (x, y) = x `member` dict &#38;&#38; y `member` dict in do (x, y) &#60;- find pairInDict pairs   Just (x ++ " " ++ y)</code></pre>
评论 #2863034 未加载
评论 #2859626 未加载
评论 #2861740 未加载
评论 #2862137 未加载
wensing将近 14 年前
Humbling way to start the work week. I could produce the fizzbuzz solution and in my sharper days the recursive backtracing one, but definitely no further.
评论 #2860324 未加载
pkteison将近 14 年前
Bit of a tangent, but a real question: If a writer doesn't approve of a site's behavior (in this case, Glassdoor is desribed as "a site that does not seem to mind when interview candidates violate NDAs"), why does the writer still link to them? Inbound links (w/o a nofollow) help sites, why help sites you don't like?
评论 #2860133 未加载
评论 #2859898 未加载
mynegation将近 14 年前
Quick heads up: page is not rendered properly in Mobile Safari on iPhone: fixed width font lines are cut off.
评论 #2860172 未加载
svdad将近 14 年前
I think the concern about whether or not candidates have seen this, or any, programming question before is missing the point. Think about what we want in the ideal candidate -- we want them to come up with a good (elegant, efficient) solution to the problem, and implement it. We (judging by all the other responses) expect them to do that because they've had a solid CS education (formal or informal) as well as significant experience.<p>But people with that background will give good answers, even if they haven't seen _this specific problem_, because they have seen lots of problems like it and recognize the pattern. And even in that case, we evaluate them based on how well they can implement the pattern they saw, not just on whether they recognized the correct algorithm. So what if they've seen this problem already? Coding it up efficiently and elegantly in an interview context is still non-trivial, and you can still push them to discuss edge cases and performance tradeoffs.<p>The person who really has _never_ seen anything like this in his life, and still can give a good answer, I have yet to meet.
Shenglong将近 14 年前
With the exception of the last part of the question, you learn everything there in your first year of CS at university. Do people who can't write this <i>really</i> put the language on their resume?<p>Can I get some stats? I really don't (want to) believe it. What percentage of people get this question wrong? Are they all some sort of eng/cs graduate? I'm not even a coder and I can solve this in a few minutes.
评论 #2860306 未加载
Havoc将近 14 年前
Its a great question. Pretty sure its not nearly as much of a secret as the author thinks though. I've seen a detailed write-up before somewhere (HN?) and I'm not even a programmer by profession.
评论 #2860155 未加载
ohashi将近 14 年前
I read this and went, I had someone build this for me years ago!<p>So I looked at the code, it used the efficient solution. Now I am even more impressed with the programmer. I've always thought highly of him (better than me) but it's hard to evaluate someone better than you. His solution ran circles around mine (I had general simple case with 2 words) and now I know exactly how much more efficient his solution was. Very neat.
mak120将近 14 年前
Its a nice Dynamic programming problem. The beauty of DP is that simply memorizing one application of it does not guarantee you a solution to an entirely different problem that might have a similar Dynamic Programming solution. Look over the TopCoder SRM archives if you don't believe me.<p>So even though you are retiring this one, coming up with something similar that tests for basically the same things shouldn't be impossible.
pavel_lishin将近 14 年前
Quick note to the author - holy god, this is annoying: <a href="http://i.imgur.com/0cNx4.png" rel="nofollow">http://i.imgur.com/0cNx4.png</a>
评论 #2863003 未加载
wisty将近 14 年前
The problem he's having is that good interview questions are getting busted, as people post solutions on the web.<p>If you have a <i>lot</i> of similar interview questions, then there's no way anyone other than a savant can memorize them without actually learning the theory.
评论 #2860180 未加载
NY_Entrepreneur将近 14 年前
The author just mentioned dynamic programming. Usually in dynamic programming, e.g., as in Dreyfus and Law, to say that a problem has a dynamic programming solution we outline the solution. But the author did not outline such a solution.<p>An outline usually includes at least the definition of the 'stages' of the dynamic programming solution. For the problem of 'string segmentation', the obvious selection of stages would be each of i = 1, 2, ..., n for the given string of length n. But this definition of the stages does not yield a dynamic program because the solution at stage i needs more than just the solution at stage i + 1 and, indeed, potentially needs the solutions at each of stages i + 1, i + 2, ..., n.<p>So, first-cut, there is no dynamic programming solution. For a second-cut, there might be a dynamic programming solution if the author would outline one!<p>There is now some question if the Google interviewers really understand dynamic programming!
评论 #2859712 未加载
评论 #2859832 未加载