public int medium() {
Node slowPtr = head;
Node fastPtr = head;
Node preSlow = head;
if (head != null)
{
while (fastPtr != null && fastPtr.next != null)
{
fastPtr = fastPtr.next.next;
preSlow = slowPtr;
slowPtr = slowPtr.next;
}
if (fastPtr != null)
{
return slowPtr.value;
}
else
{
return (slowPtr.value + preSlow.value) / 2;
}
}
return 0;
}
๐
Life has no ctrl+z
git submodule update --recursive --progress --init
-
University of Leeds
- Leeds, UK
Block or Report
Block or report 1m58s
Report abuse
Contact GitHub support about this userโs behavior. Learn more about reporting abuse.
Report abusePinned Loading
Something went wrong, please refresh the page to try again.
If the problem persists, check the GitHub status page or contact support.
If the problem persists, check the GitHub status page or contact support.