Big Integer Compare
JavaScript
Medium
2 views
Problem Description
Two big integers are given as strings (may be negative). Print -1 if A < B, 0 if equal, 1 if A > B.
Input Format
One line: A B.
Output Format
One integer -1/0/1.
Constraints
|A|,|B| length up to 1e5.
Official Solution
const fs=require('fs');const a=fs.readFileSync(0,'utf8').trim().split(/\\s+/);if(!a[0])process.exit(0);const A=BigInt(a[0]);const B=BigInt(a[1]);process.stdout.write(A<B?'-1':A>B?'1':'0');
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!