Async Count Digits
JavaScript
Easy
7 views
Problem Description
Given an integer n, count digits (ignore sign) using async function and print count.
Input Format
One integer n.
Output Format
One integer count.
Constraints
n fits in 64-bit.
Official Solution
const fs=require('fs');const s=fs.readFileSync(0,'utf8').trim();if(!s)process.exit(0);const cnt=async t=>{await Promise.resolve();let x=t.startsWith('-')?t.slice(1):t;return x==='0'?1:x.length;};(async()=>{process.stdout.write(String(await cnt(s)));})();
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!