Company: Quince_sde
Difficulty: easy
Maximize Number by Flipping a Single Digit You are given a positive integer A whose decimal digits are all 6 or 9 . A digit can be turned upside down: a 6 becomes a 9 , and a 9 becomes a 6 . You may perform at most one such flip — you may flip exactly one digit of A , or leave A completely untouched. Report the largest value that A can have afterwards. For example, take 696 . Flipping the first digit gives 996 , flipping the second gives 666 , flipping the third gives 699 , and doing nothing leaves 696 . The best of those four values is 996 . Input Format A single line containing the integer A . Output Format Print a single integer — the largest value reachable from A with at most one flip. Constraints 6 <= A <= 999999999 Every digit of A is either 6 or 9 , so A has between 1 and 9 digits. No leading zeros appear, and the number of digits never changes: a flip rewrites one digit in place. Examples Example 1 Input: 696 Output: 996 Explanation: Flipping the leading 6 up to a 9 prod