Easy Solution
Complexity\n- Time complexity: On\n\n- Space complexity: On\n\n# Code\n\n/**\n * @param {number} num\n * @return {number}\n */\nconst minMaxDifference = functio
# Complexity\n- Time complexity: On\n\n- Space complexity: On\n\n# Code\n```\n/**\n * @param {number} num\n * @return {number}\n */\nconst minMaxDifference = function(num) {\n    // tc - On, sc - On\n    // EXAMPLE: 11891\n    const nums = num.toString().split(\'\') \n\n    let nonZero\n    let nonNine\n    \n    // tc - On\n    // After this for loop nonZero = 1\n    for (const num of nums) {\n        if (num !== \'0\') {\n            nonZero = num\n            break\n        }\n    }\n\n    // tc - On\n    // After this for loop nonNine = 1\n    for (const num of nums) {\n        if (num !== \'9\') {\n            nonNine = num\n            break\n        }\n    }\n\n    // tc - On, sc - On\n    // After this for loop all 1-s will be changed to 9\n    // and nums = 99899\n    const max = Number(nums.map(num => {\n        if (num === nonNine) return \'9\'\n        return num\n    }).join(\'\'))\n\n    // tc - On, sc - On\n    // After this for loop all 1-s will be changed to 0\n    // and nums = 00890. parse int and get 890\n    const min = Number.parseInt(nums.map(num => {\n        if (num === nonZero) return \'0\'\n        return num\n    }).join(\'\'))\n\n    return max - min\n};\n```
['TypeScript', 'JavaScript']