I am getting wrong answer in Count Substring. Plz help me if u see any problem
here is link of code
http://www.codechef.com/viewsolution/4290635
As zeros is of type int, ((zeros)*(zeros+1))/2 will be computed as int, then the result is converted to long. This may overflow on some case.
There are two mistakes in your code :
-
Remove 'System.out.println(“string:”+s) ’ It’s not necessary
-
change int to long at these places :
int zeros=get_zeros(s,len);
public static int get_zeros(String s,int len)
Here is your corrected code