Skip to content

Commit ab46686

Browse files
committed
Add task definition for ReverseLinkedList task
1 parent 3d5a3ea commit ab46686

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

src/main/java/by/andd3dfx/collections/ReverseLinkedList.java

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,39 @@
11
package by.andd3dfx.collections;
22

3-
import lombok.AllArgsConstructor;
4-
import lombok.Data;
5-
63
import java.util.ArrayDeque;
74
import java.util.Deque;
5+
import lombok.AllArgsConstructor;
6+
import lombok.Data;
87

98
/**
9+
* <pre>
10+
* <a href="https://leetcode.com/problems/reverse-linked-list/">Task description</a>
11+
*
12+
* Given the head of a singly linked list, reverse the list, and return the reversed list.
13+
*
14+
* Example 1:
15+
* <img src="https://assets.leetcode.com/uploads/2021/02/19/rev1ex1.jpg"/>
16+
* Input: head = [1,2,3,4,5]
17+
* Output: [5,4,3,2,1]
18+
*
19+
* Example 2:
20+
* <img src="https://assets.leetcode.com/uploads/2021/02/19/rev1ex2.jpg"/>
21+
* Input: head = [1,2]
22+
* Output: [2,1]
23+
*
24+
* Example 3:
25+
* Input: head = []
26+
* Output: []
27+
* </pre>
28+
*
1029
* @see <a href="https://youtu.be/iEKdRgKNurg">Video solution</a>
1130
*/
1231
public class ReverseLinkedList {
1332

1433
@Data
1534
@AllArgsConstructor
1635
public static class Node<T> {
36+
1737
private T value;
1838
private Node next;
1939

0 commit comments

Comments
 (0)