FastPrepFastPrep
Problem Brief

Growth in 2 Dimensions πŸ‚

FULLTIMEOA

Start with an infinite two dimensional grid filled with zeros, indexed from (1, 1) at the bottom left corner with coordinates increasing toward the top and right. Given a series of coordinates (r, c), where r is the ending row and c is the ending column, add 1 to each element in the range from (1, 1) to (r, c) inclusive. Once all coordinates are processed, determine how many cells contain the maximal value in the grid.

Function Description

Complete the function countMax in the editor.

countMax has the following parameter(s):

  1. String[] upRight: an array of strings made of two space-separated integers representing r and c respectively

Returns

int: the number of cells that contain the maximal value

1Example 1

Input
upRight = ["1 4", "2 3", "4 1"]
Output
1
Explanation
Example 1 illustration
The two space-separated integers within each string represent r and c respectively. The following diagrams show each iteration starting at zero. The maximal value in the grid is 3, and there is 1 occurrence at cell (1, 1).

Constraints

Limits and guarantees your solution can rely on.

Unknown for now
public int countMax(String[] upRight) {
    // write your code here
}
Input

upRight

["1 4", "2 3", "4 1"]

Output

1

Sign in to submit your solution.