HaydarFakhoury's blog

By HaydarFakhoury, history, 22 months ago, In English

How can I effectively think of potential test cases that might break my approach when solving competitive programming problems? I often find it challenging to identify test cases that could potentially challenge the correctness of my solution, even after finding an approach. As a result, I may think that my approach is correct, but there could actually be a test case that my solution does not handle correctly, which I failed to consider. How can I effectively find and consider these test cases?

Not sure If everyone has or had these struggles before but I've never seen anyone point it out. Could just be me, who knows.

  • Vote: I like it
  • +2
  • Vote: I do not like it

| Write comment?
»
22 months ago, # |
  Vote: I like it 0 Vote: I do not like it

maybe use a piece of paper to list all situations

»
22 months ago, # |
  Vote: I like it 0 Vote: I do not like it

I think about problems in a very brute force approach so I often approach the problem as how to reduce redundancy and improve efficiency. Although many times, it often comes down to pattern recognition to know what works or not.

»
22 months ago, # |
Rev. 2   Vote: I like it +1 Vote: I do not like it

What I do is implement an approach(I mostly don't check before the first submission and do the following after doing a wrong submission but its not a good practice)
Your steps should be contradictory that how your solution can be failed
Like What I did in yesterday's E(but was unsolved till the end of the round) :
Maybe my choice for now is making problems for the next choices and I reached to approach in which we can change the signs of a[i] and a[i+2] without changing a[i+1]
And the real solution was I can change the signs of a[i] and a[i+k] without changing any of a[i+1],...,a[i+k-1]

I don't know if this would be or not but ...
I hope this would be helpful!