Advertisement
Is Linked List Length Even
JavaView on GFG
Is Linked List Length Even.java
Java
class Solution {
public boolean isLengthEven(Node head) {
Node curr = head;
int len = 0;
while (curr != null) {
curr = curr.next;
len++;
}
return len % 2 == 0;
}
}Advertisement
Was this solution helpful?