Javascript - simple brute force
Intuition\n Describe your first thoughts on how to solve this problem. \nSimple brute force\n\n# Approach\n Describe your approach to solving the problem. \n\n#
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nSimple brute force\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n/**\n * @param {number} num\n * @return {number}\n */\nconst getMinMaxCombo = (num, digit) => {\n\tlet max = num.toString().replaceAll(digit, \'9\');\n\tlet min = num.toString().replaceAll(digit, \'0\');\n\treturn [max, min].map(Number);\n};\n\nconst minMaxDifference = (num) => {\n\tlet [min, max] = [Infinity, -Infinity];\n\tfor (const digit of num.toString()) {\n\t\tconst [maxCombo, minCombo] = getMinMaxCombo(num, digit);\n\t\tmin = Math.min(minCombo, min);\n\t\tmax = Math.max(maxCombo, max);\n\t}\n\treturn max - min;\n};\n\n```
['JavaScript']