나는 이렇게 학습한다/Algorithm & SQL

0212. Reversed sequence

daco2020 2023. 2. 13. 00:24
반응형

Build a function that returns an array of integers from n to 1 where n>0.

Example : n=5 --> [5,4,3,2,1]



Solution:

reverse_seq = lambda n: sorted(range(1, n+1), reverse=True)
def reverseseq(n):
    return list(range(n, 0, -1))


반응형

'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글

0211. Remove duplicates from list  (0) 2023.02.12
0210. Is it a number?  (0) 2023.02.10
0209. Sort the Gift Code  (0) 2023.02.09
0209. Sort Out The Men From Boys  (0) 2023.02.09
0207. Divide and Conquer  (0) 2023.02.08