SOlution to print LCS without using direction array