Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

In one Amazon interview the guy asked a coding challenge that he had apparently come up with himself. I realized later it was NP-complete.


Is that a bad thing? A lot of real world problems don't have simple computational complexity. I'd learn more about someone from how they considered heuristic tradeoffs and assumptions that could produce a "good enough" solution to a tough problem than seeing if they could reproduce Dijkstra's algorithm from memory.


It wasn't framed as "find an approximate/heuristic solution".


You can offer. Nothing about it being NP should prevent your implementing an exact solution, though. It'll be slow as balls on (at least) some inputs, and you should surface that, but maybe they only need something that works for N<5 or something.

That's different than it being undecidable, in which case you have to insist on providing something other than an exact algorithm that handles every input.


For the short story. A few years ago I was sitting a CS exam that was 3 hours of coding and then a defense where you explained what you have done on the board.

You had to compute a graph from a set of points (i think it was knn, not sure) and do stuff on it. At some point of the defense, this happened

Me: I skipped this question.

Examinator: why?

Me: If I compute it using the graph structure, it reduces to max-clique, which is np-complete. I looked for a solution using the point dara but didn't find it

Examinator: can you write an algorithm for max-clique on the board?

Me: here. This is exponential time

Examinator: it's worst case exponential time. But in this case it would have worked, you just had to try it

Me: urgh

Now I've learned my lesson: np-complete doesn't mean impossible


That's fine. Just provide and exponential runtime algorithm and you are good.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: