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.
I think this problem could use a better definition of what a subset is. Can a single element be a subset? The examples seem to say that it can't, because all of the enumerations of subsets never show a single element. However, the inputs for the problem say that the array could be as small as a single element. So, what would be the answer in that case? Or consider a case where a single element is larger than all other possible elements combined:
100, -1, -1
In this case, if I count a single element as a subset the answer would be 100, but if it isn't, then the answer would be 99.
So, either a subset needs to include a single element. Or the constraints needs to change to say that 3 is the smallest length array possible.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Max Array Sum
You are viewing a single comment's thread. Return to all comments →
I think this problem could use a better definition of what a subset is. Can a single element be a subset? The examples seem to say that it can't, because all of the enumerations of subsets never show a single element. However, the inputs for the problem say that the array could be as small as a single element. So, what would be the answer in that case? Or consider a case where a single element is larger than all other possible elements combined: 100, -1, -1 In this case, if I count a single element as a subset the answer would be 100, but if it isn't, then the answer would be 99.
So, either a subset needs to include a single element. Or the constraints needs to change to say that 3 is the smallest length array possible.