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.
There is no need to short the array, just declare an integer variable say count=0 and than analyse if the time is <=0 increase the value of the count variable by one else leave it.
Now at the end justcheck whether count>=k or count<kand accordingly output the answer.
This will take very less time and memory.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Angry Professor
You are viewing a single comment's thread. Return to all comments →
There is no need to short the array, just declare an integer variable say count=0 and than analyse if the time is <=0 increase the value of the count variable by one else leave it.
Now at the end justcheck whether
count>=k
orcount<k
and accordingly output the answer. This will take very less time and memory.