This solution looks a little more simple than Solution 2.
I would appreciate a review - is there anything missing or less efficient?
def findMid(list):
slow = list.getHead()
if slow.nextElement == None:
return # assuming that None is an acceptable return for edge cases
fast = list.getHead()
while (slow and fast and fast.nextElement != None):
slow = slow.nextElement
fast = fast.nextElement.nextElement
return slow.data
Thanks!!