Task 1 — Maximum Value per Group
Objective
Create a function that processes a two-dimensional integer collection and finds the maximum value from each inner group.
The function must return one maximum value for every group in the input.
Input
The input is:
[][]int
Example:
data := [][]int{
{32, 12, 24, 20},
{18, 40, 22, 30},
{21, 31, 42, 35},
}
The input contains three groups.
Result Type
The function must return:
[]int
Each position in the result represents the maximum value found in the corresponding input group.
Requirements
Process every inner slice independently.
For each group:
- inspect all values in the group
- determine the maximum value
- append that value to the result
The order of the result must correspond to the order of the input groups.
Example
Given:
data := [][]int{
{32, 12, 24, 20},
{18, 40, 22, 30},
{21, 31, 42, 35},
}
the maximum values are:
Group 1 -> 32
Group 2 -> 40
Group 3 -> 42
Expected Result
[]int{32, 40, 42}
Implementation Notes
The implementation should work with other valid two-dimensional integer collections and should not depend on the example values.
The original task does not specify a function name.
Consider how the implementation should handle an empty inner group if support for such input is required.
The original specification does not define behavior for empty groups, so that behavior should be explicitly decided by the implementation rather than silently assumed.