LeetCode – Plus One Linked List (Java)
Given a non-negative number represented as a singly linked list of digits, plus one to the number. The digits are stored such that the most significant digit is at the head of the list. Example: Input: 1->2->3 Output: 1->2->4 Java Solution public ListNode plusOne(ListNode head) { ListNode h2 = reverse(head); ListNode p=h2; while(p!=null){ … Read more