result =0
for i in range(n):
data = list(map(int,input().split()))
mini = min(data)
result = max(result,mini)
I understand that you will receive a value in the list type of data until i becomes n.
But mini = min(data) If this is the case,
After receiving it once, save the smallest value in the mini
result = max(result,mini) < The value currently contained here is the smaller of the first input, so one will be saved
After that, if you receive it, isn't it going to be overwritten on the data that you received at first?
If so, the mini value will be saved again
In what form is the result stored, can you remember the largest value?
3 1 2
4 1 4
2 2 2
For example, if it was input like this, 1 would go to the value of 1 and 2 would go to the value of mini at first, but I don't understand it after that.
python
All right, so what happens right after that?
Since mini == 1, and result == 0, max(result, mini) == 1, then result = 1 is executed.
Then, the result == 1 from this point on.
What happens to the result after the second for? So what will be the result after everything is done? Think about it carefully! 😉
* If you change the name of the result variable to something like biggest_mini_ever, it might be easier to understand.
© 2024 OneMinuteCode. All rights reserved.