算法:计算单向循环链表的长度

322 阅读1分钟
// 单向循环链表长度
public static int getCircleLinkListSize(ListNode head) {

    if (head == null) {
        return 0;
    }

    ListNode point = head;

    int i = 0;
    while (point != null && point.next != head) {
        i ++;
        point = point.next;
    }

    return i + 1;
}
```
```