#How I would do this with linked list

1 messages · Page 1 of 1 (latest)

supple python
steel sealBOT
#

<@&987246399047479336> please have a look, thanks.

supple python
#

I know how to do it with arrays because I have an experience from c++ and c but its harder for me with linked lists.

#

I have all the methods implemented in my code, insertBefore, insertAfter, delete/remove, etc...

#

How would I move to next line

#

there is no for(){} here

proven swan
supple python
#

yeah but this is linked list not an array

supple python
#
public static long findMagicNumber(DLL<DLL<Integer>> list) {
        

        DLLNode<DLL<Integer>> current = list.getFirst();
        long prod = 1;
        while(current != null){
            long sum = 0;
            DLLNode<Integer> current1 = current.element.getFirst();
            while(current1!=null){
                sum+= current1.element;
                current1 = current1.succ;
            }
            prod *=sum;
            current = current.succ;
        }
        return prod;


    }
steel sealBOT
supple python
#

@proven swan can you explain the solution that I provided?