Read the question, write TypeScript on the right, then Run or Check.
QuestionHint and solution stay closed until you open them
First line n. Second line n integers. Log the max. Type the array as number[].
Examples
Input
5 3 1 8 2 4
Output
8
Input
1 42
Output
42
Hint
- const nums: number[] = readLine().trim().split(" ").map(Number);
Show correct code
Peek only after you have tried. You can still Check your own version.
const n: number = Number(readLine());
const nums: number[] = readLine().trim().split(" ").map(Number);
console.log(Math.max(...nums));
main.tstsc · readLine() · Ctrl + Enter
ResultIdle
Run to see output. Check grades the tests.