# Reverse Linked List LeetCode Solution

Here, We see Reverse Linked List problem Solution. This Leetcode problem is done in many programming languages like C++, Java, JavaScript, Python, etc., with different approaches.

## Problem Statement ->

Given the head of a singly linked list, reverse the list, and return the reversed list.

```Example 1: (fig-1)
Output: [5,4,3,2,1]```
```Example 2: (fig-2)
Output: [2,1]

Example 3:
Output: []```

## Reverse Linked List Leetcode Solution C++ ->

```.wp-block-code {
border: 0;
}

.wp-block-code > div {
overflow: auto;
}

.shcb-language {
border: 0;
clip: rect(1px, 1px, 1px, 1px);
-webkit-clip-path: inset(50%);
clip-path: inset(50%);
height: 1px;
margin: -1px;
overflow: hidden;
position: absolute;
width: 1px;
word-wrap: normal;
word-break: normal;
}

.hljs {
box-sizing: border-box;
}

.hljs.shcb-code-table {
display: table;
width: 100%;
}

.hljs.shcb-code-table > .shcb-loc {
color: inherit;
display: table-row;
width: 100%;
}

.hljs.shcb-code-table .shcb-loc > span {
display: table-cell;
}

.wp-block-code code.hljs:not(.shcb-wrap-lines) {
white-space: pre;
}

.wp-block-code code.hljs.shcb-wrap-lines {
white-space: pre-wrap;
}

.hljs.shcb-line-numbers {
border-spacing: 0;
counter-reset: line;
}

.hljs.shcb-line-numbers > .shcb-loc {
counter-increment: line;
}

.hljs.shcb-line-numbers .shcb-loc > span {
}

.hljs.shcb-line-numbers .shcb-loc::before {
border-right: 1px solid #ddd;
content: counter(line);
display: table-cell;
text-align: right;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
white-space: nowrap;
width: 1%;
}
```class Solution {
public:
ListNode *pre = new ListNode(0), *cur = head;
while (cur && cur -> next) {
ListNode* temp = pre -> next;
pre -> next = cur -> next;
cur -> next = cur -> next -> next;
pre -> next -> next = temp;
}
return pre -> next;
}
};
```Code language: C++ (cpp)```

## Reverse Linked List Leetcode Solution Java ->

``````class Solution {
}
}
```Code language: Java (java)```

## Reverse Linked List Leetcode Solution JavaScript ->

``````var reverseList = function(head) {
let [prev, current] = [null, head]
while(current) {
[current.next, prev, current] = [prev, current, current.next]
}
return prev
};
```Code language: JavaScript (javascript)```

## Reverse Linked List Leetcode Solution Python ->

``````class Solution(object):
prev = None

while curr:
next = curr.next
curr.next = prev
prev = curr
curr = next
return prev
```Code language: Python (python)```

#### House Robber LeetCode Solution

Given an integer array nums representing the amount of money of each house, return the…

#### Majority Element LeetCode Solution

Given an array nums of size n, return the majority element. The majority element is…

#### Search in Rotated Sorted Array LeetCode Solution

Given the array nums after the possible rotation and an integer target, return the index…

#### Substring with Concatenation of All Words LeetCode Solution

You are given a string s and an array of strings words. All the strings…

#### Combination Sum LeetCode Solution

Given an array of distinct integers candidates and a target integer target, return a list…

#### Divide Two Integers LeetCode Solution

Given two integers dividend and divisor, divide two integers without using multiplication, division, and mod…