Imagine you're a mathematician exploring the fascinating world of powerful integers! 🔢
Given three integers x, y, and bound, your mission is to find all the powerful integers that don't exceed the given boundary. A number is considered powerful if it can be expressed as xi + yj where both i and j are non-negative integers (≥ 0).
Your Goal: Return a list of all unique powerful integers ≤ bound. The order doesn't matter, but each value should appear only once in your result.
Example: If x=2, y=3, and bound=10, then:
- 20 + 30 = 1 + 1 = 2
- 21 + 30 = 2 + 1 = 3
- 20 + 31 = 1 + 3 = 4
- And so on...
Input & Output
Visualization
Time & Space Complexity
We generate at most log(bound) powers for both x and y, then combine them in O(log²(bound)) operations
We store the powers lists and result set, each containing at most O(log(bound)) elements
Constraints
- 1 ≤ x, y ≤ 100
- 0 ≤ bound ≤ 106
- Important: Handle cases where x = 1 or y = 1 to avoid infinite loops
- Each powerful integer should appear at most once in the result