Amazon Online Assessment (OA) 2021 - Storage Optimization | HackerRank

You have a paper box with dividers for holding wine bottles.

The box is divided by m x n dividers into (m + 1) x (n + 1) cells. Assuming the depth of the box is 1, each cell has a volume of 1.

Now we want to remove a number of dividers. Find the largest space after removing the dividers.

Example 1:


n = 5 Number of dividers in the horizontal direction

m = 5 Number of dividers in the vertical direction

h = [2, 3] Horizontal dividers to remove

v = [3] Vertical dividers to remove

Output: 6


We want to remove the 2nd and 3rd horizontal divider and the 3rd vertical divider. The largest space after removing the dividers has a volume of (4 - 1) * (4 - 2) * 1 = 6.

Try it yourself




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]

Get premium for instant access to all content and solutions