I am using charAt string method to find the sum. it works fine on online ideone compiler but when i submit it on SPOJ it's giving TLE. What's wrong? for (i=0;i<strlen;i++) { sum+=Integer.parseInt(""+str.charAt(i)); }
There are no accepted Java solutions, perhaps the startup time is too long?