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 / dgiot Goto Github PK
View Code? Open in Web Editor NEWThis project forked from dgiot/dgiot
Open source platform for IoT,30 min Quick Deployment,10M-level device connection,Carrier level Stability;物联网开源平台,30分钟快速部署,千万级承载,电信级稳定性. Zero code for Object model-Rule Engine-Data Channel-Configuration Page; Fully open source, Multi industrial protocols are compatible.物模型-规则引擎-数据通道-组态页面全流程零代码开发、前后端完全开源、多行业工业协议兼容。
Home Page: https://tech.iotn2n.com/
License: Apache License 2.0