You learned to extract digits from a number using the modulo and division trick. Take year % 10 to get the last digit, then year / 10 to remove it. Repeat until the number becomes 0.
Checking for distinct elements has multiple approaches. A hash set gives O(n) time. For just 4 digits, even nested loops (O(n²)) work fine. Choose the approach that's easiest to implement correctly.
Sometimes brute force is the right answer. If the search space is small enough and each check is fast, simple iteration beats clever algorithms. Don't over-engineer when simplicity works.