We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Python
- Numpy
- Min and Max
- Discussions
Min and Max
Min and Max
Sort by
recency
|
350 Discussions
|
Please Login in order to post a comment
My compact, one-liner solution…
After I submitted this solution, it passed all the tests, and I began posting about it here, I realized something. I didn't skip the first line of input containing
N
andM
as I usually do.But my one-liner passed all the tests anyway! I'm just lucky that making those two values part of the array didn't make any difference in the results.
The solution I should've written was…
Inspired by another user's comments about using
N
andM
, although they're not necessary, I wrote a solution that uses them…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?
Here is HackerRank Min and Max in Python solution - https://programmingoneonone.com/hackerrank-min-and-max-problem-solution-in-python.html
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)))