Reverse Maximization problem, where's my code going wrong
I am only able to score 30 with this logic.

Hey, please check the constraints for the question on the number N

You are using long long (64 bit) to store a number of 10,000 digits? long long can store ~ 18 digits only. Use strings to solve this problem.

oh! Thanks.
I was being foolish.