Last active
May 19, 2019 17:54
-
-
Save arpi-r/0f5c54080635c9194c65af1ed2034090 to your computer and use it in GitHub Desktop.
Codebuddy week13
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import heapq | |
class Solution: | |
# @param A : integer | |
# @param B : integer | |
# @param C : integer | |
# @param D : integer | |
# @return a list of integers | |
def solve(self, A, B, C, D): | |
l = [A, B, C] | |
ol = l[:] | |
heapq.heapify(l) | |
vis = [] | |
res = [] | |
i = 0 | |
while( i < D ): | |
m = heapq.heappop(l) | |
if m in vis: | |
continue | |
vis.append(m) | |
res.append(m) | |
i = i + 1 | |
for j in range( len(ol) ): | |
heapq.heappush( l, ol[j] * m ) | |
return res |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment