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

Beginner - Lost Without a Map

daco2020 2022. 4. 7. 20:36
반응형

Description:

Given an array of integers, return a new array with each value doubled.

For example:

[1, 2, 3] --> [2, 4, 6]

 

 

Solution:

1. Get the elements out of the array.
2. Multiply the element by 2 and put it back into the array.
3. Return an array.

 

def maps(a):
    return list(map(lambda x: x * 2, a))

The lambda function is an anonymous function and is suitable for simple calculations.

 

 

 

 

반응형

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

Total amount of points  (0) 2022.04.09
Transportation on vacation  (0) 2022.04.08
Calculate average  (0) 2022.04.07
Hide Kata Description  (0) 2022.04.05
How Green Is My Valley?  (0) 2022.04.04