10 Toughest Google Interview Questions and Answers

Page 10 of 10

1. Model Raindrops Falling on a Sidewalk (sidewalk is 1m and raindrops are 1cm). How Can We Know When the Sidewalk is Completely Wet?

Software Engineer

Here’s how you can model it in Python

import math

#Length and width of sidewalk in meters

sidewalk_length = 1.0

sidewalk_width = 1.0

#Diameter of a raindrop in meters

raindrop_diameter = 0.01

#Area of the sidewalk

sidewalk_area = sidewalk_length * sidewalk_width

#Area of a single raindrop

raindrop_radius = raindrop_diameter / 2

raindrop_area = math.pi * (raindrop_radius ** 2)

#Number of raindrops required to cover the entire surface of the sidewalk

num_raindrops = math.ceil(sidewalk_area / raindrop_area)

print(“The number of raindrops required to cover the entire surface of the sidewalk is:”, num_raindrops)

Insider Monkey focuses on uncovering the best investment ideas of hedge funds and insiders. Please subscribe to our free daily enewsletter to get the latest investment ideas from hedge funds’ investor letters by entering your email address below. You can also take a peek at 21 Best Selling Phones of All Time and 15 Cheapest Countries for Retirement.

Page 10 of 10