• + 2 comments

    Thanks for the idea... but i have one doubt... for instance take input: 4 5 2 8 3 7 Here, total no. of pairs : 2 8 = divide 3 8 = not divide 3 7 = divide 2 3 = divide 8 7 = divide 2 7 = not divide

    so, Answer should be 2 which is case with (3,8) and (2,7) Now, according to your idea... lets i am using array so,

    image

    Now here, as showing my loop will go through 2 index... but as k/2 (5/2) so, max of a[2] and a[3] is 2 and thatsit.... resulting my answer is 2 only.... but it should be 4 as we are counting total pair which are evenly divisble