The trick is that a "beautiful" year has all distinct digits. Given a year like 2023, you need to find the next year where no digit repeats. You could check each year one by one: extract its digits and verify they're all different.
A year has at most 4 digits, so checking distinctness is fast. To extract digits, repeatedly take year % 10 (last digit) and year / 10 (remaining digits). Store digits in a set or array to check for duplicates.