Problema
Count down from start to 1, then add "Liftoff!". Each number becomes one text entry.
Implement countdown(start).
Input
start: The number to start counting down from.
Output
Return the countdown as a list of strings, ending with "Liftoff!".
Restricciones
0 ≤ start ≤ 1,000
Ejemplos
Entrada:
start = 3
Salida esperada:
expected = ["3", "2", "1", "Liftoff!"]
Entrada:
long long start = 3;
Salida esperada:
std::vector<std::string> expected = {"3", "2", "1", "Liftoff!"};
Entrada:
long start = 3;
Salida esperada:
string[] expected = new string[] {"3", "2", "1", "Liftoff!"};
Explicación
"3", "2", "1", then "Liftoff!".
Entrada:
start = 0
Salida esperada:
expected = ["Liftoff!"]
Entrada:
long long start = 0;
Salida esperada:
std::vector<std::string> expected = {"Liftoff!"};
Entrada:
long start = 0;
Salida esperada:
string[] expected = new string[] {"Liftoff!"};
Explicación
There is nothing to count, so only "Liftoff!" remains.
Cómo abordarlo
Inténtalo primero por tu cuenta y luego abre las pistas una a una.
Pista 1
Build the list by stepping downward from the starting number until you reach 1.
Pista 2
Generate each entry as text, then append the final farewell message at the end.
Pista 3
Remember the smallest input can skip the numeric loop and still return only the farewell.
Complejidad esperada
O(start) time, O(start) extra space
Referencias
Este reto está adaptado para CodeUtility. Sigue el enunciado y las restricciones indicadas arriba.