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.
You're looping two times over the list. You can avoid this by deleting the k-th item from the list with del ar[k], just substracting it from the sum or using reduce instead of sum + list comprehension, even though it's not necessary for the test cases.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Bill Division
You are viewing a single comment's thread. Return to all comments →
You're looping two times over the list. You can avoid this by deleting the k-th item from the list with
del ar[k]
, just substracting it from the sum or using reduce instead of sum + list comprehension, even though it's not necessary for the test cases.