코딩 테스트/leetcode
Neither Minimum nor Maximum
ornni
2024. 6. 28. 10:00
728x90
반응형
첫번쨰 코드
가장 큰 값, 가장 작은 값이 아니면 그냥 return 해버리고,
다 돌았는데 아무것도 이루어지지 않으면 -1을 return 해버리면 된다!!
class Solution:
def findNonMinOrMax(self, nums: List[int]) -> int:
Max = max(nums)
Min = min(nums)
for i in nums:
if i != Max and i != Min:
return i
return -1
통과!
링크
https://github.com/ornni/leetcode/tree/main/2733-neither-minimum-nor-maximum
leetcode/2733-neither-minimum-nor-maximum at main · ornni/leetcode
Collection of LeetCode questions to ace the coding interview! - Created using [LeetHub v3](https://github.com/raphaelheinz/LeetHub-3.0) - ornni/leetcode
github.com
반응형