Max Score in Roe

Problem 5

Problem Statement

There are N x M students in the class. Each student was given a score. On the ground all students are arranged in an Nx M grid M students in each row. Now, your task is to find the maximum score in each row and print them.


Input Format:

  • The first line contains an integer T, the number of test cases.
  • The first line of each test case contains two positive integers N and M
  • The next N lines contains M inputs of the matrix

Output Format:

  • For each test case, print all the maximum scores of students in each row separated by spaces.

Constraints:

  • 1 <= T <= 10
  • 1 <= N, M <= 100
  • 1 <= A[i][j] <= 105 for all 1 <= i <= N && 1 <= j <= M
Sample Input
Sample Output

Solution

file_type_python max_score_in_row.py
for _ in range(int(input())):
    r, c = list(map(int, input().split()))
    m = [list(map(int, input().split())) for i in range(r)]
    print(*[max(mxRow) for mxRow in m])

Comments

Load Comments