반응형
In this kata you will create a function that takes in a list and returns a list with the reverse order.
Examples (Input -> Output)
* [1, 2, 3, 4] -> [4, 3, 2, 1]
* [9, 2, 0, 7] -> [7, 0, 2, 9]
Solution:
List<int> reverseList(List<int> list) {
return list.reversed.toList();
}
List<int> reverseList(List<int> list)=>[...list.reversed];
List<int> reverseList(List<int> list) => List.from(list.reversed);
반응형
'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글
1119. Return Negative (0) | 2022.11.19 |
---|---|
1118. Function 1 - hello world (0) | 2022.11.18 |
1116. Convert boolean values to strings 'Yes' or 'No'. (0) | 2022.11.17 |
1115. Reversed Strings (0) | 2022.11.15 |
1114. Exclamation marks series #6: Remove n exclamation marks in the sentence from left to right (0) | 2022.11.14 |