Every i write code on codechef it shows correct output for sample cases but when i submit i display wrong answer,what can i do to solve these problems
If the output of your program does not match what the judges expect, you will get a Wrong Answer notification. Generally, incorrect output occurs because you have either misunderstood the problem, missed a trick in the question, did not check the extreme conditions. Just because your test cases passes on the sample cases does NOT mean that it will pass on all the extreme cases as well.
If you’re trying to solve a problem which is NOT from a live contest, you could share the problem and your solution here, and someone experienced enough might be able to help you out.
Just to add, some really basic tactic that I (and I am sure a lot of other people) use is to write down some random test generator, create a slow brute-force solution that works perfectly on smaller test cases, and use the two programs to create like 1000 tests and their solutions and check them against my solution-to-be-submitted. This way I catch some cases I didn’t think about.