Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3c38511

Browse files
committed
Refactoring LinkedList
1 parent 3c2cf8d commit 3c38511

File tree

2 files changed

+44
-12
lines changed

2 files changed

+44
-12
lines changed

‎src/linkedlists/ReverseSinglyLinked.java‎

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package linkedlists;
2+
3+
import java.util.LinkedList;
4+
5+
/**
6+
* Given the pointer/reference to the head of a singly linked list,
7+
* reverse it and return the pointer/reference to the head of reversed linked list.
8+
*/
9+
10+
public class SinglyLinkedList{
11+
12+
static Node head;
13+
14+
static class Node{
15+
16+
public int data;
17+
public Node next;
18+
19+
Node(int a, Node next){
20+
this.data = a;
21+
this.next = next;
22+
}
23+
}
24+
25+
public static void main(String args[]){
26+
27+
LinkedList<Integer> list1 = new LinkedList<>();
28+
list1.add(7);
29+
list1.add(14);
30+
list1.add(21);
31+
list1.add(28);
32+
33+
System.out.println(list1);
34+
reverse_list(list1);
35+
36+
}
37+
38+
39+
40+
private static void reverse_list(LinkedList<Integer> list1) {
41+
// TODO Auto-generated method stub
42+
43+
}
44+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /