Thanks sir for reply i am trying and willing to improve with your guidance.
but the major problem i was getting was thinking why the two sequences increasing and decreasing marked by i and j .wont have a common element which has not to be counted for twice by the method?