C++20 sections · 1024 units
Open in Course

Problem - Beautiful Year

Finding distinct digits

You're given a year. Your task: find the next year where all four digits are distinct. For example, if the input is 1987, you need to find 2013 (since 1988-2012 all have repeated digits).

This problem tests your ability to extract digits using the modulo (%\%) and division (// ) operators. You'll need to check if all four digits of a number are different from each other.

The challenge involves iteration and digit manipulation. You'll start from the next year and keep checking until you find one with all distinct digits.