You are given a number n in the form of a string. This number may also be negative.
You are also given a single digit x (from 1 to 9).
Your task is to insert this digit x into the number n at any position (except before the - sign if the number is negative) such that the resulting number becomes as large as possible.
You must return the resulting number as a string.
Input: n = "-72", x = 5
Output: "-572"
Explanation:
To maximize a negative number, insert where the value becomes least negative.
Input: n = "56", x = 7
Output: "756"
Explanation:
Inserting 7 at the beginning creates the highest value.
Accepted:
Submission: