반응형
Given an array of integers your solution should find the smallest integer.
For example:
- Given [34, 15, 88, 2] your solution will return 2
- Given [34, -345, -1, 100] your solution will return -345
You can assume, for the purpose of this kata, that the supplied array will not be empty.
Solution:
# 1
def find_smallest_int(arr):
return sorted(arr, reverse=True).pop()
# 2
def find_smallest_int(arr):
return min(arr)
# 3
find_smallest_int = min
반응형
'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글
1020. Convert a string to an array (0) | 2022.10.20 |
---|---|
1019. Is it a palindrome? (0) | 2022.10.19 |
1017. Enumerable Magic - Does My List Include This? (0) | 2022.10.17 |
1016. Multiplication table for number (0) | 2022.10.17 |
1015. simple calculator (0) | 2022.10.15 |