Skip to content

Instantly share code, notes, and snippets.

@arpi-r
Last active May 19, 2019 17:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arpi-r/0f5c54080635c9194c65af1ed2034090 to your computer and use it in GitHub Desktop.
Save arpi-r/0f5c54080635c9194c65af1ed2034090 to your computer and use it in GitHub Desktop.
Codebuddy week13
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