#How I would do this with linked list
1 messages · Page 1 of 1 (latest)
<@&987246399047479336> please have a look, thanks.
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
then implement it
yeah but this is linked list not an array
I found the solution
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;
}
Detected code, here are some useful tools:
@proven swan can you explain the solution that I provided?