Given the head of a singly linked list and a 1-based integer k, return the value of the kth node from the beginning. k is always valid (1 <= k <= n).
Input: Head of a singly linked list and integer k (1-based).
Output: Integer value of the kth node.
Input: [1,2,3,4,5], 3
Output: 3
Explanation: 3rd node = value 3.Input: [1,2,3,4,5], 1
Output: 1
Explanation: 1st node = head = 1.Input: [1,2,3,4,5], 5
Output: 5
Explanation: 5th (last) node = 5.1<=nodes<=10^5-10^9<=Node.val<=10^91<=k<=n