Skip to content

Commit

Permalink
206
Browse files Browse the repository at this point in the history
  • Loading branch information
isinsuarici committed Apr 20, 2022
1 parent 7ad158a commit 5f5c291
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions E_206_ReverseLinkedList.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode() {}
* ListNode(int val) { this.val = val; }
* ListNode(int val, ListNode next) { this.val = val; this.next = next; }
* }
*/
class Solution {
public ListNode reverseList(ListNode head) {

ListNode header=null;
while(head!=null){
ListNode next=head.next;
head.next=header;
header=head;
head=next;

}
return header;
}
}

0 comments on commit 5f5c291

Please sign in to comment.