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.
publicstaticintcookies(intk,List<Integer>A){// Write your code herePriorityQueue<Integer>pq=newPriorityQueue<>(A);intcount=0;while(pq.size()>1&&pq.peek()<k){pq.offer(pq.poll()+2*pq.poll());count++;}returnpq.peek()>=k?count:-1;}
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 →
In JAVA8 :