Min and Max

Sort by

recency

|

349 Discussions

|

  • + 1 comment

    Though, range M is not required, but its still always a good practice to do so to exactly respect the question asked. And that's why I intentionally invoked this to keep the N * M Matrix. What do you think? Please let me know your opinion?

    import numpy
    
    N, M = list(map(int, input().split()))
    
    array_lst =[]
    
    for _ in range(N):
        inp = input().split()
        lst = [int(inp[i]) for i in range(M)]
        array_lst.append(lst)
        
    np_array = numpy.array(array_lst)
    max_array= numpy.min(np_array, axis= 1)
    print(numpy.max((max_array)))
    
  • + 0 comments

    Here is HackerRank Min and Max in Python solution - https://programmingoneonone.com/hackerrank-min-and-max-problem-solution-in-python.html

  • + 0 comments
    import numpy as np
    
    n, m = map(int, input().split())
    
    val = np.array([list(map(int, input().split())) for i in range(n)])
    
    print(np.max(np.min(val, axis=1)))
    
  • + 0 comments

    import numpy

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

    data = []

    for _ in range(n): data.append(list(map(int, input().split())))

    array = numpy.array(data)

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

  • + 0 comments
    import numpy as np
    
    a = np.array([list(map(int, input().split(' '))) for _ in range(int(input().split(' ')[0]))])
    a = np.min(a, axis=1)
    
    print(np.max(a))