Interview-Questions icon indicating copy to clipboard operation
Interview-Questions copied to clipboard

Crazy hard question

Open santhoshvai opened this issue 9 years ago • 2 comments

Same problem??

  • http://stackoverflow.com/questions/21060873/minimum-sum-that-cant-be-obtained-from-a-set
  • https://www.codechef.com/JAN14/problems/FRBSUM

santhoshvai avatar Aug 18 '15 11:08 santhoshvai

I find this solution to be easy:

Sort(A)
candidate = 1
for i from 1 to length(A):
   if A[i] > candidate: return candidate
   else: candidate = candidate + A[i]
return candidate

First solution is crazy. :1234: will look into it and let u know.

prakashn27 avatar Aug 19 '15 07:08 prakashn27

I can also understand this. The challenge is to do it in less than O(n lgn). O(n) solution needed

santhoshvai avatar Aug 19 '15 07:08 santhoshvai