# What to do at the time of Wrong Answer (WA)?

There is been always a case that a wrong answer gives too much pain rather than TLE (Time Limit Exceed), as in former you couldn’t ascertain about which test case it is failing but in later you can estimate that for which value of N (Total instruction), it would show TLE.

**So What to do at that time?**

**Read Question Carefully:**At the first time, when you got WA(Wrong Answer) then always be sure that you have read each and every word and fully understand the question because most of the time we skipped that particular part which is the base of whole question.-
**Check Input/Output formatting:**Mostly Programmers usually forget to add new line or white space according to the requirement of question. So before submitting the solution to Online judge, try to run your program in online compilers like code.geeksforgeeks.org or ideone. -
**Check Algorithm/Logic of program:**Be sure that you are using correct logic that are covering all the test cases or not. -
**Corner test cases**Try to run your code on boundary test cases, if possible like 0, 1, 2 or N.

**Avoid Silly Mistakes**

**Initialize variable:**Sometimes we forget to reinitialize variables, arrays after every test case T. For example-- Initialize the value of count variable to 0.
- Setting all value of DP[] array to 0 or -1.

So input same or different test case atleast twice and check if correct output is obtained or not.

**Data type Overflow:**Always keep the constraint given on value of N or other input in your mind, and make your program in the range of correct data type like int, long long in C/C++ or int, long in JAVA etc to avoid overflow.**Modular Problem:**In questions like Modular Arithmetic (answer % MOD),always ensure that answer is not getting a negative value, so try to use (answer + MOD) % MOD, that will cover all possibilities.

**Debugging**

**The most important part is debugging:**You can either use inbulit debugger of Codeblock, Ecllipse in C/C++ and JAVA respectively or you can print the variable after each and every line so that you can estimate that your program is running according to your requirement or not.**Use Assertion:**If you are going to write a plenty of lines in your code then using assert() is totally worth it. Click here to read more about how to use Assertion in Competitive programming.**Look for Suggestions given:**Although this should be the last step but you must look at the comments given below in which other programmers might have also facing the same problem and have given a hint on how to eradicate this issue.

** Ultimately, always try to write a clean code with a small function that have well defined purpose.**

This article is contributed by Shubham Bansal. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.

## Recommended Posts:

- How to overcome Time Limit Exceed(TLE)?
- Sqrt (or Square Root) Decomposition | Set 2 (LCA of Tree in O(sqrt(height)) time)
- Find the arrangement of queue at given time
- Find the minimum time after which one can exchange notes
- Extended Mo's Algorithm with ≈ O(1) time complexity
- Dynamic Programming | Wildcard Pattern Matching | Linear Time and Constant Space
- Number of ways to arrange K different objects taking N objects at a time
- Game Theory in Balanced Ternary Numeral System | (Moving 3k steps at a time)
- Find the time which is palindromic and comes after the given time
- time.h localtime() function in C with Examples
- Find minimum number of steps to reach the end of String
- Count possible combinations of pairs with adjacent elements from first N numbers
- Count of Subsets of a given Set with element X present in it
- Find two equal subsequences of maximum length with at least one different index