-
Notifications
You must be signed in to change notification settings - Fork 19k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implementation of poll() Method for Singly Linked List #5229
Comments
class ListNode{ |
hi there! if you allow me I would like to work on this issue |
/assign |
class ListNode {
} class SinglyLinkedList {
} public class Main {
} |
hi @srprawinraja I have implemented the poll method but the required checks are failling I have done code right. |
The poll() method is used to remove and return the head value of a singly linked list. To make this method robust and handle edge cases properly, we need to consider the following: Handle the case where the list is empty (i.e., head is null). Singly Linked List Implementation public class SinglyLinkedList {
} |
What would you like to Propose?
The poll() method is a new feature introduced to optimize the removal and retrieval of the head node's value in a singly linked list.
Issue details
Additional Information
public int poll() {
if (head == null) {
return -1; // Return a default value or handle empty case
}
int headValue = head.val;
head = head.next;
return headValue;
}
The text was updated successfully, but these errors were encountered: