Given the head of a singly linked list and an integer val, delete the last occurrence of a node with value val. Return the head.
If val is not found, return the list unchanged.
Input: Head of a singly linked list and integer val.
Output: Head of the updated linked list.
Input: [1,2,3,2,4,2,5], 2
Output: [1,2,3,2,4,5]
Explanation: Last occurrence of 2 is at position 6. Delete it.Input: [1,2,3], 1
Output: [2,3]
Explanation: Only occurrence of 1 is the head. Delete head.Input: [1,2,3], 4
Output: [1,2,3]
Explanation: 4 not found. Return unchanged.1<=nodes<=10^5-10^9<=Node.val<=10^9