Help me in String and Number

problem
Getting tle
my solution

Change

st=st+"1";

to

st+="1";

and the same for "0". The former creates a whole new copy of st; appends 1 to it; and re-assigns it to st, making this an O(|s|^2) operation when performed over the whole of s.

5 Likes

I don’t think function will work Bin_to_Dec.
|s|<=10^5

bro thanks so much but now it is giving

Consider the test input:

1
abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 
1 Like

giving answer
-291172004

Yes, I know :slight_smile:

1 Like

what i do now

  1. Use the test input I gave you to diagnose the problem.

  2. Fix the problem :slight_smile:

1 Like

yes
i have done if(max<0) then max=0;
but till giving wa

I have check one corect solution and giving 291172004
to your input

I have correct answer for your input not getting ac

Consider the test input:

1                                                       
abbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
1 Like

779551928
answer from my code

MY solution

please help me

See what is the largest number you can store in dec_value

i cannot get what you mean

Take example when string length is 70 and see what is stored in dec_value. Try printing the value before taking its mod. You will know then. Take this case

1
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
1 Like

value is -1