1 1 k l books not working for this test case, your code
did the test cases include many mappings to ‘.’ ??
Shortest representation of 000.000 should be 0. Empty string can not be a valid representation.
and it was a decimal number ultimately…
i think your case is not covering for the test case 000000000000 or 00000.000
just after one replacement flag them like for str[i] u have done replacement then take another bool array foo[100000] and at foo[i] make it equal to 1 and at the end of the loop again initialise all elements of array foo = 0;
you have not used newline in printf as"\n" like for printf(“0”) u have to write like printf(“0\n”)
what is your output for test case 1: 0
case 2 : 000000000000000000000
The question says shortest representation for 0.5 is .5 and for 5.0 it is 5. The question didn’t mention about any order that we have to follow… So keeping both things in mind how can shortest representation of 0.0 be 0
@minato_namikaz:
1
0
00.
the o/p should be “0”. ur code prints ‘.’ - it is not a valid decimal number…
@rkm123:
Ur program works fine when there is only 1 test case… but when 2 or more are given… the results are wrong.
2
3
0 .
. 9
5 0
95.0
0
01800
try the above one… You will understand where you went wrong 
what are you getting for test case 00.00100 ?
once try to check it
@brobear1995 okay i understood that encrypted string is books.
but it was clearly mentioned in the problem “After all the character replacements, the string is guaranteed to be a positive decimal number.”
So as far as I understood, Test cases should be such that, after replacements it will be giving a decimal number.
Please correct me if i’m wrong.
its gives 0… gives correct for tricky and normal tests… the tested program is up on ideone link provided
it is showing runtime error in ideone see here zHklFb - Online C Compiler & Debugging Tool - Ideone.com
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
I am getting .001 only…
You can check on this:
the input itself is invalid!!!