A bit of linked list action in python. This can be optimized further because the dict only contains continuous numbers (other than 0) so we shouldn't need: a dict whose key is the cup value, and where each entry is a node containing the next cup. Instead we can have a list whose index is the cup value and where each entry contains the next cup. The two are basically equivalent, but the list is faster.
A bit of linked list action in python. This can be optimized further because the dict only contains continuous numbers (other than 0) so we shouldn't need: a dict whose key is the cup value, and where each entry is a node containing the next cup. Instead we can have a list whose index is the cup value and where each entry contains the next cup. The two are basically equivalent, but the list is faster.