Async Absolute Value
JavaScript
Easy
5 views
Problem Description
Given an integer n, print its absolute value using async/await style.
Input Format
One integer n.
Output Format
One integer.
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 abs=async t=>{await Promise.resolve();const x=BigInt(t);return x<0n?-x:x;};(async()=>{process.stdout.write((await abs(s)).toString());})();
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!