Problem Β· Array

Prison Break πŸͺ΄

Learn this problem
● EasyIxlFULLTIMEOA

Problem statement

A prisoner is planning to escape from prison! The prison's gate consists of horizontal and vertical bars that are spaced one unit apart, so the area of each hole between the bars is 1 x 1. The prisoner manages to remove certain bars to make some bigger holes. Determine the area of the largest hole in the gate after the bars are removed.

Function

prison(n: int, m: int, h: int[], v: int[]) β†’ int

Complete the function prison in the editor below.

prison has the following parameter(s):

  1. n: an integer, the number of horizontal bars
  2. m: an integer, the number of vertical bars
  3. int h[]: an array of integers, the horizontal bars to remove
  4. int v[]: an array of integers, the vertical bars to remove

Returns

int: the area of the largest hole in the gate after the bars are removed

Examples

Example 1

n = 6m = 6h = [4]v = [2]return = 4
Example 1 illustration
In the images below, the left image depicts the initial prison gate with n = 6 horizontal and m = 6 vertical bars. The area of the biggest hole in the bars is 1 x 1. The right image depicts that same gate after the prisoner removes horizontal bar 4 and vertical bar 2, at which point the area of the biggest hole in the bars becomes 2 x 2 = 4.

Constraints

Unknown for now 🦜

More Ixl problems

drafts saved locally
public int prison(int n, int m, int[] h, int[] v) {
    // write your code here
}
n6
m6
h[4]
v[2]
expected4
checking account