Company: TSMC
Difficulty: medium
Remove Nodes Greater Than X Given a singly linked list and an integer, x, remove nodes greater than x. Function Description Complete the function removeNodes in the editor below. The function must return a reference to the root node of the final list. Parameters: node listHead : a reference to the root node of the singly-linked list int x : the maximum value to be included in the returned singly-linked list Constraints 1 ≤ n, x ≤ 10 5 1 ≤ SinglyLinkedListNode values ≤ 10 5 Input Format for Custom Testing Input from stdin will be processed as follows and passed to the function: The first line contains an integer n, the number of nodes in the linked list. The next n lines each contain an element to insert into the linked list. The last line contains x, the maximum value allowable in the linked list. Examples Sample Case 0 Input: 5 1 2 3 4 5 3 Output: 1 2 3 After removing the nodes having a value > 3, list = 1 → 2 → 3. Sample Case 1 Input: 5 5 2 1 6 7 5 Output: 5 2 1 After removing the no