Cisco OA-9 2023
Problem Description
In theoretical mathematics, a 'Happy Number' is defined as a number that, when repeatedly replaced by the sum of the squares of its digits, eventually reaches 1. Numbers that do not reach 1 will get trapped in a cycle that excludes 1.
Your task is to write a program to determine the maximum size of a set of UNIQUE happy numbers within the range from X to Y. Return 0 if there are no happy numbers in that range. A happy number is considered UNIQUE in the set if no other number in the set can be formed by rearranging its digits.
Input
There are two numbers X and Y representing the low and high end of the range. The range includes X and Y.
The first line represents the low end i.e. X.
The second line represents the high end i.e. Y.
Output
Maximum size among the subsets of a set of UNIQUE happy numbers.
Constraints:
0 <= X,Y <= 10^5