Analysis:
Using the mafia fight method, find the smallest prime and multiply with the additional list to store the ugly numbers then adding the relevant indexes of them. Finally pop the last element.
Time Complexity:
- O(m*n)
Space Complexity:
- O(n)
Code
1 | class Solution: |