http://www.codechef.com/viewsolution/1745517
this is the accepted solution of the problem I got TLE on my submission so I modified the code which is exactly similar to the above one but Iβm still getting TLE.
My solution : http://www.codechef.com/viewsolution/1760327
Please tell me how is this happening ?
@yashvardhan90 :
i=n-1;
if( a[i]==βFβ || a[i]==β?β)
if( a[i-1]==βEβ || a[i-1]==β?β)
if( a[i-2]==βHβ || a[i-2]==β?β)
if( a[i-3]==βCβ || a[i-3]==β?β)
The top most line βi=n-1β is the βculpritβ . Why should it be here inside the while loop ???
Your loop never ends , for say a string of size 20 .
1 Like