Skip to content
Programming101
Programming101

Learn everything about programming

  • Home
  • CS Subjects
    • IoT – Internet of Things
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
Programming101
Programming101

Learn everything about programming

HackerRank Min and Max problem solution in python

YASH PAL, 31 July 2024

In this Min and Max problem, You are given a 2-D array with dimensions N X M. Your task is to perform the min function over axis 1 and then find the max of that.

HackerRank Min and Max solution in python

Problem solution in Python 2 programming.

import numpy
l=map(int,raw_input().split())
m=[]
for i in range(l[0]):
    m.append(map(int,raw_input().split()))
m=numpy.array(m)
print max(numpy.min(m,axis=1))    

Problem solution in Python 3 programming.

import numpy

n,m=map(int,input().split())

lista=[list(map(int,input().split())) for i in range(n)]

ar=numpy.array(lista)

print(max(numpy.min(ar,axis=1)))

Problem solution in pypy programming.

# Enter your code here. Read input from STDIN. Print output to STDOUT
import numpy
N, M = map(int, raw_input().split())
myarr = []
for _ in range(N): 
    myarr.append(map(int,raw_input().split()))
print numpy.max(numpy.min(myarr, axis = 1), axis = 0)

Problem solution in pypy3 programming.

# Enter your code here. Read input from STDIN. Print output to STDOUT
N, M= [int (i) for i in input().split()]
arr=[]
for i in range(N):
    arr.append( [int(x) for x in input().split()]  )
ma=arr[0][0]
for i in range(N):
    mi=arr[i][0]
    for j in range(1,M):
        if (arr[i][j]<mi):
            mi=arr[i][j]
    if (mi>ma):
        ma=mi
print(ma)

coding problems python

Post navigation

Previous post
Next post
  • How AI Is Revolutionizing Personalized Learning in Schools
  • GTA 5 is the Game of the Year for 2024 and 2025
  • Hackerrank Day 5 loops 30 days of code solution
  • Hackerrank Day 6 Lets Review 30 days of code solution
  • Hackerrank Day 14 scope 30 days of code solution
©2025 Programming101 | WordPress Theme by SuperbThemes