Reverse a Sequence
easy⏱ 15 mintypescriptchallengesproblem-solving-basic-
Runs in your browser
- Before starting
- Use a supported browser; initial dependencies may need internet.
- What it proves
- Run shows output; Test checks the authored cases, not every possible input.
- When finished
- Stop active runs when finished. No cloud infrastructure is provisioned by this exercise.
LEARN BY DOINGPut your intuition to work3 steps
Reverse a Sequence
Use the lesson’s examples and explanation to check your idea.
Personal reflection. Nothing is sent to an AI service.Before you start
Browser lesson checks; review each requirement in Tests.
Catalog level: Easy · Estimated time: 15 min. Your prior experience can change the difficulty.
5 4 3 2 1
Sample case — your program reads stdin and prints to stdout.
Need a hand?
Start with a small test case. Hints progress from an idea to an explanation and, when requested, code.
Starter Given a sequence of n integers, reverse it in place and print the result.
This simulates reversing a linked list - use two pointers or stack approach.
Example: [1,2,3,4,5] → [5,4,3,2,1]
Input format
Line 1: n. Line 2: n space-separated integers.
Output format
The reversed sequence as space-separated integers.
Constraints
0 ≤ n ≤ 5000