We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
if (ln == 0 and k > 0):
return -1
count = 0
if (ln > 0):
while((i + j + 1 < len(arr) + len(arr2)) and ((len(arr) > i and arr[i] < k) or (len(arr2) > j and arr2[j] < k))):
count += 1
firstSmallest, i, j = getElement(arr, arr2, i, j)
secondSmallest, i, j = getElement(arr, arr2, i, j)
newCookie = firstSmallest + (2 * secondSmallest)
arr2.append(newCookie)
if ((len(arr) > i and arr[i] < k) or (len(arr2) > j and arr2[j] < k)):
count = -1
return count
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Jesse and Cookies
You are viewing a single comment's thread. Return to all comments →
Python Solution with using Heap directly,