1. Condensed List Given a list of integers, remove any nodes that have values that have previously occurred in the list
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
1. Condensed List Given a list of integers, remove any nodes that have values that have previously occurred in the list
1. Condensed List Given a list of integers, remove any nodes that have values that have previously occurred in the list and return a reference to the head of the list. For example, the following list has a recurrence of the value 3 initially: Function Description Complete the function condense in the editor below. Returns Linked List 3 6 head tail Redundant nodes are colored with the same color 4 Constraints • 1≤n≤ 105 • 0 ≤ LinkedListNode.val < 1000 3 head Redundant nodes are removed after calling 4 condense has the following parameter(s): head: the head of a singly-linked list of integers, a LinkedListNode 3 reference to LinkedListNode: the head of the list of distinct values Remove the node at position 2 in the list above, O based indexing. Note:. A LinkedListNode has two attributes: data, an integer, and next, a reference to the next item in the list or the language equivalent of null at the tail. 6 tail condense 亩 197 @一亩三分地
▾ Sample Case 1 Sample Input 1 1 GRGL Sample Output 1 NO Explanation 1 Consider the robot's initial orientation to be facing north toward the positive y direction. The robot performs the following four steps in a loop: 1. Go forward one step. The robot moves from (0, 0) to (0, 1). 2. Turn right. The robot turns eastward, facing the positive x direction. 3. Go forward one step. The robot moves from (0, 1) to (1, 1). 4. Turn left. The robot turns northward, facing the positive y direction again. ↑ RG → LG ↑ RG → LG 亩 @一宙三分地 ↑ G The robot then repeats these steps infinitely, following an endless zig-zag path in the northeasterly direction. Because the robot will no in such a way that it would be restricted to a circle, set index 0 of the return array to NO.