Tell me what is problem in your code. Whether I need to change your algorithm?