In an interview I was asked to design the system that calculates the number of ads that will be displayed to a user after each query made on google search engine. May I know your solutions/approaches/algorithms to deal with this problem?