Read the question, write TypeScript on the right, then Run or Check.
QuestionHint and solution stay closed until you open them
Print second largest among distinct ints.
Examples
Input
3 1 8 2
Output
3
Hint
- sort unique desc
Show correct code
Peek only after you have tried. You can still Check your own version.
const nums: number[] = [...new Set(readLine().trim().split(/\s+/).map(Number))].sort((a, b) => b - a);
console.log(nums[1]);
main.tstsc · readLine() · Ctrl + Enter
ResultIdle
Run to see output. Check grades the tests.