Implement uniform sampling in squares | Uber Interview Question