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.
Originally I looked at the max value in each list, used abs() on it in case it is negative and then squared it and found the sum of these max for all the lists. It only passed a few tests. Then I used product() as suggested here. But how is product any different. It map(sum, itertools.product(*ls)) will add up all the elements squared which means the biggest numbers in the lists will be added and hence still have the same effect. Anyone could please explain or perhaps show me a usecase where my original algorithm would fail? Thanks a lost
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Maximize It!
You are viewing a single comment's thread. Return to all comments →
Originally I looked at the max value in each list, used abs() on it in case it is negative and then squared it and found the sum of these max for all the lists. It only passed a few tests. Then I used product() as suggested here. But how is product any different. It map(sum, itertools.product(*ls)) will add up all the elements squared which means the biggest numbers in the lists will be added and hence still have the same effect. Anyone could please explain or perhaps show me a usecase where my original algorithm would fail? Thanks a lost