Tuesday, July 13, 2010

Find three numbers in an array

Given an array of integers A, find the largest c such that c=a+b. a, b, c are in A.

2 comments:

  1. Sort the list in reverse order using QuickSort (worst case O(n*log(n))) and then largest sum will be A[0] + A[1]

    ReplyDelete
  2. no. c must be in A. otherwise is trivial

    ReplyDelete