Implement sampling, subarray scan, and percentile estimate | Google Interview Question