Count Substring WA

Why am I getting wrong answer for Count Substrings

Here is the solution

You are mostly not getting a WA…you are getting a RE(with regard to the soln link that you have shared above)…i.e. runtime error…and that is due to the size of the array…its size should the atleast the max length of the input string + 1…for the ‘\0’ in the end…also there are few other mistakes in your code…

  1. Time complexity to high…try to reduce it!!!

  2. The data type of your counter variable is not big enough to store the final ans…and hence will eventually give a WA…try using long long!!!

Hope this helps…:slight_smile: