Statistics

Problem Statement for "GridGenerator"

Problem Statement

Consider the following grid of numbers:
 1 0  3  4   1
 4 5  8  15  20
 1 10 23 46  81
 0 11 44 113 240
 3 14 69 226 579
Aside from the top row and left column, each number is equal to the sum of the three numbers immediately left, above, and above-left of it. You will be given a int[], row, representing the first row of a similar grid, and a int[], col, representing the first column of the grid. Your task is to return the value of the lower rightmost location when the values are calculated in the same way. Hence, the above example would be represented by the input row = {1,0,3,4,1}, col = {1,4,1,0,3}.

Definition

Class:
GridGenerator
Method:
generate
Parameters:
int[], int[]
Returns:
int
Method signature:
int generate(int[] row, int[] col)
(be sure your method is public)

Constraints

  • row and col will contain the same number of elements.
  • row and col will contain between 2 and 10 elements, inclusive.
  • Each element of row and col will be between 0 and 9, inclusive.
  • The first element of row will be the same as the first element of col.

Examples

  1. {1,0,3,4,1}

    {1,4,1,0,3}

    Returns: 579

    The example above.

  2. {9,9,9,9,9,9,9,9,9,9}

    {9,9,9,9,9,9,9,9,9,9}

    Returns: 13163067

    The largest possible return.

  3. {0,0,0,0,0,0,0,0,0}

    {0,0,0,0,0,0,0,0,0}

    Returns: 0

  4. {1,5,3,1,2,9}

    {1,3,1,5,9,7}

    Returns: 5027

  5. {1,2}

    {1,3}

    Returns: 6

  6. {1, 1 }

    {1, 1 }

    Returns: 3

  7. {1, 0, 3, 4, 1 }

    {1, 4, 1, 0, 3 }

    Returns: 579

  8. {1, 1 }

    {1, 1 }

    Returns: 3

  9. {1, 0, 3, 4, 1 }

    {1, 4, 1, 0, 3 }

    Returns: 579

  10. {1, 1 }

    {1, 1 }

    Returns: 3

  11. {1, 0, 3, 4, 1 }

    {1, 4, 1, 0, 3 }

    Returns: 579


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: