implement BigInt subtraction with sign
2022年5月1日小于 1 分钟
implement BigInt subtraction with sign
Question
This is a follow-up on 75. implement BigInt subtraction.
You are asked to implement a string substraction function, with possible negative integers. Also, '+' plus sign should also be supported
substract('-999999999999999999', '-1')
// '-999999999999999998'
substract('-999999999999999999', '+1')
// '-1000000000000000000'
Don't use BigInt directly, it is not our goal here.
Code
/**
* @param {string} num1
* @param {string} num2
* @return {string}
*/
function subtract(num1, num2) {
// your code here
}