def solution(sizes):
answer = 0
# The smallest of the horizontal gyrings, the smallest of the verticals,
# When you change the horizontal and vertical, if the value is less than the max of the changed value. It's not valid.
# I don't think it's that important You can sort the list and find the maximum value there.
sizes = [sorted[s] for s in sizes]
answer = max([x[0] for x in sizes]) * max([x[1] for x in sizes])
return answer
When executing the above code
TypeError: 'builtin_function_or_method' object is not subscriptable
This error appears.
def solution(sizes):
sizes = [sorted(s) for s in sizes]
return max([x[0] for x in sizes]) * max([x[1] for x in sizes])
However, if you do not accept the value as a variable and return it immediately, the error does not appear. Why?
coding-test python
The above function is sorted[s], so you can change it to sorted(s).
© 2024 OneMinuteCode. All rights reserved.