Nevermind i read your code.

Your algorithm is wrong. what you are doing here is adding up the complete
binary numbers A and B every time a query is made.
Instead use something like a bitvector for java to store the two binary
numbers and another bit vector to store C, and another to store the carry
forwards let it be X.
Initially sum both the numbers according to your method and save C and the
carry array X.

Now when a set query is made. let it be seta 3 1.
So you need to consider only three or four cases at max. the lower bits in
the summation will not change.
Now set A[3] to 1 and just compute C[3] = A[3] + B[3] + X[3];
if the sum is greater than 2. check X[4] if it's is 0 set X[4] to 1 and
compute C[4] and so on.

Sukun Tarachandani
IDD Electrical Engineering(2nd year)
IIT Roorkee


On Sat, May 5, 2012 at 9:37 AM, Sukun Tarachandani <[email protected]>wrote:

> I meant what is your algorithm, are you summing up the entire numbers A
> and B every time a set query is made?
>
> Sukun Tarachandani
> IDD Electrical Engineering(2nd year)
> IIT Roorkee
>
>
> On Fri, May 4, 2012 at 11:32 PM, Umer Farooq <[email protected]> wrote:
>
>> They haven't shared the rest of test cases. However, the execution time
>> difference is extremely high.
>>
>> It took about 0.3 and 0.6 sec for the cases in which it executed
>> successfully. However, it was taking more than 5 sec on test cases in which
>> it couldn't run.
>>
>>
>> On Fri, May 4, 2012 at 10:26 PM, vIGNESH v <[email protected]>wrote:
>>
>>>
>>> Hai
>>>
>>> Can you brief about the rest of the cases?
>>>
>>> On 4 May 2012 01:56, Umer Farooq <[email protected]> wrote:
>>>
>>>> Hi friends!
>>>>
>>>> I hope that you are doing really good these days.
>>>>
>>>> I submitted my code on interviewstreet.com
>>>>
>>>> The problem statement can be found on
>>>> https://www.interviewstreet.com/challenges/dashboard/#problem/4f1c739a6ea3a
>>>>
>>>>
>>>> However, it passed for only two cases and gave a time out error for the
>>>> rest of cases. Can anyone please tell me where I am lacking?
>>>>
>>>> Is there anything I can do to improve the running time of my code?
>>>>
>>>> I thought it was because Java runs slower, but they have a greater
>>>> limit of running time for java code.
>>>>
>>>> Please find the code in the attachment.
>>>>
>>>> --
>>>> Umer
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Algorithm Geeks" group.
>>>> To post to this group, send email to [email protected].
>>>> To unsubscribe from this group, send email to
>>>> [email protected].
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>
>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Algorithm Geeks" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected].
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>
>>
>> --
>> Umer
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to