come on dude, thats just another case. Cant you modify the code yourself to accommodate all these scenarios ? I was just trying to give you the logic/algo, not the exact code. I dont think it will be much hard now, Give it shot. e are not supposed to give you the complete code anyway. If you want i can modify the code for you, but i dont think that will help you in long run.