Required String Check
JavaScript
Easy
3 views
Problem Description
One line text is given. If after trim it becomes empty, throw error EMPTY and print EMPTY. Else print trimmed length.
Input Format
One line string.
Output Format
One line output.
Constraints
String length up to 2e5.
Official Solution
const fs=require('fs');const raw=fs.readFileSync(0,'utf8');const s=raw.replace(/\
?\
$/,'');try{const t=s.trim();if(!t)throw new Error('EMPTY');process.stdout.write(String(t.length));}catch(e){process.stdout.write(e.message);}
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!