Skip to content

Commit

Permalink
Update Reverse_linked_list.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Asmi1108 authored Nov 3, 2024
1 parent 8844f43 commit 9e46751
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions java/Reverse_linked_list.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
---
id: Reverse_Linked_List
id: reverse-linked-list
sidebar_position: 1
title: Reverse Linked List
sidebar_label: Reverse Linked List
description: "This document explains the reversing a linked list in java."
description: "This document explains reversing a linked list in java."
tags: [java, data structures, linked list]
---

# *Reverse Linked List*
# *Reversing a Linked List*

## *Description*

Given a singly linked list, reverse the order of its nodes.

## *Approach*

- *Steps:*
*Steps:*

1. Initialize three pointers: `prev`, `cur`, and `next`.
2. Traverse the linked list.
Expand Down Expand Up @@ -92,11 +92,9 @@ Reversed List:
```


- *Time Complexity*
-- O(n), where n is the number of nodes.
- *Time Complexity*: O(n), where n is the number of nodes.

- *Space Complexity*
--O(1), as only a constant amount of space is used.
- *Space Complexity*: O(1), as only a constant amount of space is used.

# *Conclusion*
In this article, we learned about reversing a linked list and implemented it in Java.

0 comments on commit 9e46751

Please sign in to comment.