Thanks for the explanation. I got it. I thought that only difference between two consecutive numbers should be similar in longest subsequence. Got it and can modify my already existing algo accordingly.