Problem
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!".
Constraints
0 ≤ start ≤ 1,000
Examples
Input:
start = 3
Expected output:
expected = ["3", "2", "1", "Liftoff!"]
Input:
long long start = 3;
Expected output:
std::vector<std::string> expected = {"3", "2", "1", "Liftoff!"};
Input:
long start = 3;
Expected output:
string[] expected = new string[] {"3", "2", "1", "Liftoff!"};
Explanation
"3", "2", "1", then "Liftoff!".
Input:
start = 0
Expected output:
expected = ["Liftoff!"]
Input:
long long start = 0;
Expected output:
std::vector<std::string> expected = {"Liftoff!"};
Input:
long start = 0;
Expected output:
string[] expected = new string[] {"Liftoff!"};
Explanation
There is nothing to count, so only "Liftoff!" remains.
How to approach it
Try on your own first, then open one hint at a time.
Hint 1
Build the list by stepping downward from the starting number until you reach 1.
Hint 2
Generate each entry as text, then append the final farewell message at the end.
Hint 3
Remember the smallest input can skip the numeric loop and still return only the farewell.
Expected complexity
O(start) time, O(start) extra space
References
This challenge is adapted for CodeUtility. Follow the statement and constraints above.