Hacker News new | ask | show | jobs
by napo 1480 days ago
I'm surprised that atm there is a consensus in the comments saying that it's not cheating. Companies ask interviewers to not reveal the questions they had to other candidates. It's likely that his friend was told not to say that. Overall he clearly had an unfair advantage, and even if legally it wouldn't be the definition of "cheating" it would go against the intent of the interview: which is to evaluate candidates in front of a new problem.

Kudos to the author for being honest about all this. I think it's a real issue and that we should find more solutions to prevent this than candidates signing an NDA. Imho when doing such interview, questions should not rely on a "trick" and even if they do, candidates should be evaluated on everything else: how they explain the code, how they react to feedbacks, how easily they transcribe what they explain to code. It's not perfect but it helps.

9 comments

Companies can ask whatever they want. They will ask for two weeks notice but lay you off with no notice. Who gives a fuck what companies ask for?

Don’t pretend they are an authority. They’re a bunch of idiots making it up as they go along like the rest of us.

I don’t disagree with anything you said. However, if the prevailing attitude was “fuck these companies that pay me these privileged tech salaries”, we’d all be treated much worse.
It's not "fuck them", it's just don't confuse a business relationship with a social relationship. Companies don't pay high salaries because they want to be nice, they do it because the market requires it. The second the market stops requiring it, they'll stop doing it. They'll treat employees only as well as the market and the law requires, employees should do the same or they'll be taken advantage of.
I'm shocked too.

Comapre it with people who applied too, but didn't have that "internal" knowledge

Is it fair from that "not well networked" person perspective?

It's not even like he found this question randomly on the internet, he got it from MSFT employee, lol.

I have really mixed feelings about this

Edit.

Don't get me wrong, apparently author was(and is) capable of doing his job, so it isn't a big problem, but what if author wasn't capable of doing the job and passed just due to the advantage?

I know person who told beginner programmer what X company asks on interviews and that guy actually managed to pass that interview due to the knowledge

but was fired like 3 months later due to lack of skills

> but what if author wasn't capable of doing the job

Than Microsoft would've been scammed out of $350 worth of plane tickets, $150 worth of hotel commodations and $1000 worth of employee time. Hardly the end of the world for a multi billion dollar company

> and passed just due to the advantage?

Passed a six hour Microsoft on-site grilling due to knowing the question for a 15 minute off-site interview question?

> Is it fair from that "not well networked" person perspective?

Fairness becomes a bit of a contrived concept once you start to factor in higher order effects. Then it just turns into fair if it advantages me, and unfair if it doesn’t.

I helped a friend get a job once because I knew who was going to interview him, and I knew he had a blog where he published all his thought-leader technical opinions.

Is that fair or unfair? Probably neither. It’s more of a random coincidence that my friend benefitted from this. But is it fair that I have learned more about my local industry by going to industry events and listening to people present things, and talking to people, etc? That probably is fair, and that’s how I learned the tip I gave to my friend.

Fairness isn’t really relevant to the problem here. If you believe that there is a problem at all, then the problem is that the screening process can be influenced by random coincidence.

I disagree. He heard about this question beforehand during a casual encounter with an employee. So what? The onus is on Microsoft to have a more robust process than using basic riddles like those.

Would he have chosen to volunteer the info, he would have actively decided to penalize himself against all the other candidates who had also heard about this question before. This would have been borderline stupidity.

What about a case where the interviewee is given an obscure problem to solve, yet already encountered and solved the problem in a different context?

It would be difficult to classify as cheating if they did not learn about about the question from an inside source. On the other hand, it also defeats the presumed purpose of the question (i.e. to test problem solving skills).

I was in that situation before, explained how I knew the solution, and did not get the job. While there were probably other reasons for their decision, they said they wanted to give the position to someone who was pursuing a career in software development, at the end of the day the candidate is going to be up against people who would offer up the solution with out further explanation. That is an awfully good way to stifle opportunities based upon the presumed (and possibly incorrect) intent of the question.

A good example to make this question more fair, as an interviewer, would be to rapidly give the (n-1)*n/2 trick quickly if the candidate doesn't know it. And not care too much if they do know it.
While I can absolutely see why people would view this as cheating, I'm also not sure what he was suppose to do. It's a case of: "Hey, look, I really want this job so I took the time to prepare and studied the kind of question you might ask. I happen to know the answer to this question, could you ask a new one that I don't know the answer to?" If I where the interviewer, I'd just stop the interview at this point and move the candidate along to the next interview anyway. He's clearly smart enough and has already invested time.

Personally I don't put a ton of value in question like this, so I'm less inclined to view it as cheating, and more like proper preparation... and a bit of luck.

You tell the interviewer you are familiar the question instead of pretending to come up with a solution on the spot. Is that not obvious to everyone?
Low risk, high reward.

Close to 0% chance someone would find out, as that would involve the person revealing the question also facing consequences - unless the company has some elaborate scheme involving modified and unique questions tailored for each candidate, and keeping track what candidate got which question. But that obviously wouldn't work with a trivial question like the one OP got.

Either that, or some third party which could have intercepted the communication between OP and the friend revealing the question. But again, what are the chances...

And on a tangent - should candidates "grinding leetcode" reveal that they've encountered the question before? That's the whole point of leetcode.

> "Low risk, high reward."

I've seen candidates deny that they've seen the problem given, blitz through the basic version (intended as a quick warm-up), and then completely choke when a slight twist is added. Let's just say that really raises some questions...

> Companies ask interview[ees] to not reveal the questions they had to other candidates.

I'm not condoning the author's actions, but I don't think any company has explicitly told me that. (I assume by "interviewers" you meant "interviewees.")

yes, ty tbh both interviewers and interviewees are asked not to share interview questions
It's not even a trick, though. The sum of zero and n is n. The sum of 1 and n-1 is also n. So is the sum of 2 and n-2, and so on. There are n+1 numbers when counting from zero to n, and they can be paired so that each pair adds up to n.

It's a pretty obvious thing that anyone who spent much time thinking about math as a kid or teenager would have encountered, and maybe that's who MS wanted to hire! Especially back then when more of their programming needs dealt with algorithms and mathematical thinking, as opposed to gluing libraries together, I think it makes some sense.

Isn't this the famous Gauss proof/algorithm that he came up with when he was 5 or something?
I'm sure he got there earlier than almost anyone!

Just googled it, and it looks like he did is a little differently. He paired 1 with n and then 2 with n-1, etc... yielding n/2 pairs that add up to n+1. It still works out to (n+1) * n/2, though :)

Apparently biographers disagreed about his age at the time but they all had the same method and the same problem of summing numbers from 1 to 100.

That story is apocryphal.
It's a quiz problem, and it's supposed to have "trick" solutions.

However, if he wants to play that game, he should provide proof of his solution, not fiddle with syntax or error checking. That's why discussion is more important, and how he can show that understands what he's doing and not just memorizing tricks. (... none of which matters for his future role anyway.)

The formula "falls out" naturally if you're used to working with summations:

Σi = Σ(n-i+1) = n² - Σi + n

2Σi = n² + n

... but the xor solution is more elegant.

I came up with another solution (which is purposefully complicated): It is known that the sum of n-th roots of unity is zero. So if we choose the n-th roots of unity as ω and calculate Σ ω^ai, the result should be 0 + ω^(the duplicate number).

So I opened the python interpreter, and I used this very trivial method of calculation (instead of summing the sine and cosine functions independently), and using asin and acos functions, got the result. It turned out to be accurate for n=1e6 with an error of ~1e-5. So it should be usable for much bigger n too.

In my view the trick in this question is to think about adding up numbers not how you add them up.Since this was a programming question you don't need to know the formula you can add up the numbers in a loop. It wouldn't even be much slower since you need a loop of size N anyway for the purpose of adding up numbers in the input.

Xor solution and adding solutions are the same solution it's just a matter of what binary function you use for calculating sum. You can use any commutative, associative binary function which has inverse. You can use addition, xor or even multiplication.

xor will not overflow and is obviously correct.

I'm not sure modulus-addition would be correct.

I learned this formula before high school. It was considered trivial.

The demonstration was to write the sums 1+2+...N and N+(n-1)+...+1 and add them up position wise. The sum comes n*(n+1)/2 (divide by 2 for the two sums).