"Nandish KB",
Somebody probably should have mentioned it sooner, but your name does not quite meet our
Naming policy. You need a real sounding first AND last name (although initials for a first name are allowed). We'd appreciate it if you'd change it by going
here. Now, about your question...
forget about java for a minute. if i said to you "i'm going to recite some numbers. when i'm done, tell me the 13th from last one", how would you do it? think about what you need to remember, and what you can forget, and when.
write out the steps you'd take on paper, or post them here, and we'll be happy to review them with you. Once you have that, writing the code is much easier.