Company: IBM
Difficulty: medium
Question 2 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 Returns: node : a reference to the root node of the final list Constraints 1 ≤ n ≤ 10 5 1 ≤ SinglyLinkedListNode values ≤ 10 5 Example List = 100 → 105 → 50 x = 100 List becomes 100 → 50 Code Template class Result { /* * Complete the \'removeNodes\' function below. * The function is expected to return an INTEGER_SINGLY_LINKED_LIST. * The function accepts following parameters: * 1. INTEGER_SINGLY_LINKED_LIST listHead * 2. INTEGER x */ /* * For your reference: * SinglyLinkedListNode { * int data; * SinglyLinkedListNode next; * } */ public static SinglyLinkedListNode removeNodes(SinglyLinkedListNode li