Google Online Assessment (OA) - Maximum Area Serving Cake

Given an array of positive integers representing the radii of circular pizzas and the number of guests at a movie party, return the size of the largest piece of pizza (rounded to 4 decimal places) that can be cut so that every guest gets a slice of pizza with the same size. It is not possible that a single slice has some part of one pizza and some part of another pizza, and each guest gets only once slice of pizza.

Constraints:

  • 1 <= number of pizzas <= 1000
  • 1 <= radii[i] <= 1000
  • 1 <= number of guests <= 1000

Examples

Example 1:

Input:

radii = [1, 1, 1, 2, 2, 3]

guests = 6

Output: 7.0686
Explanation:

You can divide the pizza with a radius of 3 by 4: area 28.743 / 4 = 7.0686 to get 4 slices. Get the remaining 2 slices from the pizzas wth radius 2 because they have an area larger than 7.0686.

Example 2:

Input:

radii = [4, 3, 3]

guests = 3

Output: 28.2743

Example 3:

Input:

radii = [6, 7]

guests = 12

Output: 21.9911

Try it yourself

Solution

Title

Script

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.

Contrary to popular belief, Lorem Ipsum is not simply random text.

  >>> a = [1, 2, 3]
  >>> a[-1]
  3

Get premium for instant access to all content and solutions

Upgrade