3 ms·
2 hardest google questions I've been asked (or at least that I remember being asked) one I did reasonably well on, but it threw me for a loop for the rest of th
by compsciphd 9y ago
2 hardest google questions I've been asked (or at least that I remember being asked) one I did reasonably well on, but it threw me for a loop for the rest of the interview as I kept on thinking about it and one I did terribly on as it didn't give me anywhere to start.
1. Estimate Pi using a unit circle inscribed in a unit square with the ability to increase/decrease accuracy.
For some reason I had calculus on the brain, so went with a reimann sum type approach (i.e. accuracy would be how wide the rectangles were.
What they wanted was a monte carlo approach. i.e. throw darts, measure how many are inside and outside the circle but within the square.
2. Write a regex matcher that can match letters/numbers/./*
#2 is basically from Kernighan and Pike's practice of programming, except as Kernighan comments elsewhere Rob Pike required an hour or 2 to figure it out (not something I think is reasonable to accomplish in 30-45m of time in an interview)
though after that, I decided to learn more about regex's and wrote my own full regex parser (including grouping, back and forward expressions....), wasn't performant (and could die in the well known pathalogical cases), but it was fun to learn.