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 d575faa

Browse files
Create 21-03-2024.cpp
1 parent 44c3a2c commit d575faa

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

‎2024/03 - March/21-03-2024.cpp‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
3+
Author : Manas Rawat
4+
Date : 20/03/2024
5+
Problem : Merge In Between Linked Lists
6+
Difficulty : Medium
7+
Problem Link : https://leetcode.com/problems/merge-in-between-linked-lists/description
8+
Video Solution : NA
9+
10+
*/
11+
12+
13+
/**
14+
* Definition for singly-linked list.
15+
* struct ListNode {
16+
* int val;
17+
* ListNode *next;
18+
* ListNode() : val(0), next(nullptr) {}
19+
* ListNode(int x) : val(x), next(nullptr) {}
20+
* ListNode(int x, ListNode *next) : val(x), next(next) {}
21+
* };
22+
*/
23+
class Solution {
24+
public:
25+
ListNode* reverseList(ListNode* head)
26+
{
27+
vector<int>help;
28+
ListNode* temp=head;
29+
while (temp!=nullptr)
30+
{
31+
help.push_back(temp->val);
32+
temp=temp->next;
33+
}
34+
temp=head;
35+
for (int i=help.size()-1;i>=0;i--)
36+
{
37+
temp->val=help[i];
38+
temp=temp->next;
39+
}
40+
return head;
41+
}
42+
};

0 commit comments

Comments
(0)

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