In this line of your code(this can be a problem if your logic is correct…i haven’t checked yet…maybe there can be any other reason)
for(i=0;i<strlen(str);i++)
str[i]=arr[str[i]];
Here you are calculating the size of string in every iteration due to “strlen(str)” which is having time complexity of O(length(str)) making the time complexity of loop as O((length(str)) ^ 2)…
i was also getting TLE for same reason but thanks to a question on SPOJ and its forum that they told where I was making mistake
hi…I usually code in java…and I referred to the Editorialist’s solution for this problem. With all due respect, I think there is one case where the output’s not valid…
Input:
1
1
z .
343z.89
Output:
343…89
Well, is it or is it not a valid output ?
P.S. : No disrespect to anyone considering I’m just a newbie.
The constraint actually states : " All characters in S and ci may be any ASCII printable character except space and pi is a digit (“0” - “9”) or a decimal point “.” "…I’m confused. How’s the input invalid ? Pls elaborate.
hey, guyz … i am new here … my solution is giving right answer for every test case but still WA . plzz can any one tell me my mistake or test case which i am missing … . please help me friends .
I not have much knowledge of java but I think u are using s.length in loop condition so It increse your complexity to O(s.length^2). so separate calculate s.length and store in local variable and use as condition. For tle may be anY other reason…
@rudra_nitpsarraf ,No one mentioned it because “only” is written i.e, only factional part is present with no integral part… they also showed it using leading examples {(0.5=.5) and (5.0=5)}…
Is there any way to find out which test case a solution failed on? This was a pretty straight forward implementation but it got WA. http://www.codechef.com/viewsolution/4081801