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;
}
1m58s / mall4cloud Goto Github PK
View Code? Open in Web Editor NEWThis project forked from gz-yami/mall4cloud
⭐️⭐️⭐️ Springcloud商城 O2O商城 小程序商城 PC商城 H5商城 APP商城 Java商城 分销商城 多用户商城 uniapp商城 微服务商城
License: GNU Affero General Public License v3.0