News for hackers. Stuff that matters.
Re:Whiteboard interviews are a test of obedience, not intell... by whimsicalism on Monday June 03, 2024 @06:50PM (#40568569)
Whenever someone tells me they've been asked a leetcode hard in an interview, I always ask them "which one". I don't think I've ever gotten a response that was an actual LC hard.

This is the only LC hard I've ever been asked in an actual interview https://leetcode.com/problems/shortest-path-in-a-grid-with-o...

Re:Whiteboard interviews are a test of obedience, not intell... by titanomachy on Monday June 03, 2024 @07:01PM (#40568696)
I once got asked something like this (at Google): https://leetcode.com/problems/expression-add-operators/descr...

Pretty sure all the others were easy or medium.

Re:Whiteboard interviews are a test of obedience, not intell... by tzs on Monday June 03, 2024 @10:37PM (#40570153)
I'm curious why the rated that one hard.

They say the maximum length of the input digit string is 10, so there are at most 9 places where an operator can be inserted. At each possible insertion point there are 4 possibilities: insert one of the 3 allowed operators or do not insert anything.

That's only 262144 possible expressions. Just brute force evaluating all of them, filtering out the ones that do not equal the target, and then filtering out those that violate the no leading zeros requirement should be fast enough even on a slow computer.

The other hard ones I've seen have all allowed inputs large enough that brute forcing would be way too slow, and so cleverness is required. E.g., that shortest path in a grid problem that was posted a comment or two above. My first thoughts on that one were to just generate all possible paths with the obstacles ignored, and then find the shortest path(s) that do not cross more than the number of obstacles we are allowed to eliminate.

But the grid can be up to 40x40. By 10x10 we're already up to 41044208702632496804 possible paths [1], so brute force is not an option.

[1] https://oeis.org/A007764

Re:Whiteboard interviews are a test of obedience, not intell... by titanomachy on Tuesday June 04, 2024 @09:02AM (#40574142)
When I got this in an interview they definitely wanted better than brute force.
Re:Whiteboard interviews are a test of obedience, not intell... by whimsicalism on Tuesday June 04, 2024 @11:40AM (#40575738)
really? it says it’s a backtracking solution. i imagine you could speed it up a bit by memoizing, but it would still be pretty brute force
Re:Whiteboard interviews are a test of obedience, not intell... by Mystrl on Monday June 03, 2024 @08:27PM (#40569369)
Oh hey that's the question I got for my recent amazon onsite (slightly different constraints). I couldn't find the exact question online and I thought it was a "fair" medium question. IMO this is a pretty good question there's a really easy suboptimal solution so people don't get completely stuck, the optimizations are pretty straightforward and there's a lot of room to demonstrate you can write clean code.

*Fair meaning there's no crazy tricks to it or any obscure algorithms just applying DSA fundamentals.

Re:Whiteboard interviews are a test of obedience, not intell... by jmd42 on Monday June 03, 2024 @09:14PM (#40569671)
Right - I think it's fair to expect somebody to come up with some kind of approach to solving this, even if they've never encountered the problem or drilled Leetcode before. At least to be able to conceptualize the problem and make a decent attempt.

I wouldn't expect more than brute force. But being able to reason about this, having some working familiarity with graphs etc, is not an unfair bar.