Google Interview Question

finding the biggest sum of subset in an int array.

Interview Answers

Anonymous

Oct 23, 2010

No sorting, it takes O(n) time.

1

Anonymous

Jul 16, 2010

What are the specifics to this question? Are we asked to find the subset with number of elements k from a superset of size n, that has the largest sum? ... should just sort the set and sum the largest k elements. O(whatever you choose, if you know the range and its small, counting sort, otherwise nlogn)

Anonymous

Jan 18, 2011

Just iterate through the array and add positive numbers to the sum. I don't think this was the problem..

Anonymous

Jan 31, 2011

Iterate through the subset once and find the two biggest numbers. Add them to get your answer.