Program for following problem

Jun 18, 2013 at 6:28am
Integer V lies strictly between integers U and W if U < V < W or if U > V > W. A non-empty zero-indexed array A consisting of N integers is given. A pair of indices (P, Q) where 0 ≤ P < Q < N is said to have adjacent values if no value in the array lies strictly between values A[P] and A[Q]. For example, in array A such that A[0] = 0 A[1] = 3 A[2] = 3 A[3] = 7 A[4] = 5 A[5] = 3 A[6] = 11 A[7] = 1 the following pairs of indices have adjacent values: (0, 7), (1, 2), (1, 4), (1, 5), (1, 7), (2, 4), (2, 5), (2, 7), (3, 4), (3, 6), (4, 5), (5, 7).

Need Optimal solution
Jun 18, 2013 at 6:56am
AFAIK no one on this site shall be willing to make this program for you from scratch. Try to make an attempt yourself and people shall help you out if you face any difficulties.
Jun 18, 2013 at 7:40am
Last edited on Jun 18, 2013 at 7:49am
Jun 18, 2013 at 9:41am
@abhishekm71 -- I have implemented it...but in normal way.. So need some optimal solution

@Smac89 : Thanks :)
Topic archived. No new replies allowed.