@Terence: It is subtraction of 2 lists and not addition. N for your logic of
addition for x>9 you add px+1 and after that if it becomes > 9 how do you
know the previous of it as you've moved the previous pointer?

Can someone comment on my logic ?

On Wed, Aug 25, 2010 at 9:10 PM, Raj N <[email protected]> wrote:

> They've mentioned that they're large lists. What if it is a 15 digit
> number? Its not efficient then.
>
>
> On Wed, Aug 25, 2010 at 8:29 PM, Sathaiah Dontula <[email protected]>wrote:
>
>> @Raj,
>>
>> How about doing like below ?
>>
>> Convert A to base 10 number, numA
>> Convert B to base 10 number, numB,
>> Then take the difference  numC = abs(numA - numB),
>> Then convert numC to linked list with the digits
>>
>> any comments ?, overflow condition is the problem here.
>>
>> Thanks & regards,
>> Sathaiah Dontula
>>
>> On Wed, Aug 25, 2010 at 3:24 PM, Raj N <[email protected]> wrote:
>>
>>> Input : Two large singly linked lists representing numbers with most
>>> significant digit as head and least significant as last node.
>>> Output: Difference between the numbers as a third linked list with
>>> Most significant digit as the head.
>>> Eg:
>>> ---
>>> Input:
>>> A = 5->4->2->0->0->9->0->0
>>> B = 1->9->9
>>> Output:
>>> C = 5->4->2->0->0->7->0->1
>>> Required complexity :
>>> O(n)
>>> Constraint:
>>> Reversing linked list is NOT allowed
>>>
>>> --
>>> 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]<algogeeks%[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]<algogeeks%[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