Companies like Facebook are completely retarded. Do they really expect programmers or software engineers to know or memorize every common algorithm in Computer Science?
Do they really expect a programmer to come up with a good algorithm to a randomly chosen problem within 20 minutes, or even 20 hours? I’m sure the person who came up with the original algorithm for the subset sum problem spent days (or weeks!) to arrive at a reasonably optimized solution.
Just as no developer writes software from scratch (instead relying on third-party libraries and frameworks), most developers will Google for a solution to a well-known problem, because programmers are not walking encyclopedias.
By using “whiteboard” interviews to screen candidates, these companies are very likely passing up on perfectly good software engineers who doubtless can do the job in any real-world setting, not in an artificial, severely time-limited control. Technical recruiters and HR staff are simply too damn lazy to do their jobs, instead looking for easier and more convenient hiring practices (which don’t work!).
What’s wrong with the tried-and-true hiring methods? Talk to the candidate and get a feel for the person’s character and work ethos. Look at their resumés and confirm their references. Check out their previous work products (such as GitHub repos, side projects, websites, etc.). Look at their other qualities besides just coding ability, such as communication skills, people skills, time management skills, and so on. Developers usually have to work in a team, talking to other people, writing clear documentation, and meeting deadlines. You want well-rounded individuals for the job.
These things are old school, and they work. Stop being so damn lazy!