반응형
No Loops Allowed
You will be given an array a
and a value x
. All you need to do is check whether the provided array contains the value, without using a loop.
Array can contain numbers or strings. x
can be either. Return true
if the array contains the value, false
if not. With strings you will need to account for case.
Looking for more, loop-restrained fun? Check out the other kata in the series:
Solution:
def check(arr, x):
import collections
return bool(collections.Counter(arr).get(x))
반응형
'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글
1025. Exclusive "or" (xor) Logical Operator (0) | 2022.10.26 |
---|---|
1024. Sum The Strings (0) | 2022.10.24 |
1022. Area of a Square (0) | 2022.10.22 |
1021. USD => CNY (0) | 2022.10.21 |
1020. Convert a string to an array (0) | 2022.10.20 |