Practice Tenth Line
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Print only the tenth line of file.txt. Earlier and later lines must not be printed. If fewer than ten lines exist, print nothing. Practice approach: Use a line-number-aware tool, for example sed with automatic output disabled and an explicit print for line ten, or awk selecting NR == 10. A head/tail pipeline needs care: on a short file it can accidentally print the last available line. Include both a file longer than ten lines and a short file when checking the command.
Source: Tenth Line on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
one two three four five six seven eight nine ten eleven
ten
The tenth line is ten; the eleventh line is ignored.
Constraints
Related LeetCode Problems
Practice more problems similar to Tenth Line.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.