Practice Maximum Value after Insertion
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
You are given a very large integer n, represented as a string, and an integer digit x. The digits in n and the digit x are in the inclusive range [1, 9], and n may represent a negative number. You want to maximize n's numerical value by inserting x anywhere in the decimal representation of n. You cannot insert x to the left of the negative sign. Return a string representing the maximum value of n after the insertion.
Source: Maximum Value after Insertion on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
n = "99", x = 9
"999"
# Example 2
n = "-13", x = 2
"-123"
Constraints
Related LeetCode Problems
Practice more problems similar to Maximum Value after Insertion.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.