Skip to content

Commit 30f6a18

Browse files
committed
Updated
1 parent 8155076 commit 30f6a18

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

dsa-solutions/lc-solutions/2500 - 3000/2807-insert-greatest-common-divisors-in-linked-list.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
id: insert-greatest-common-divisors-in-linked-list
3-
title:Insert Greatest Common Divisors in Linked List
3+
title: Insert Greatest Common Divisors in Linked List
44
sidebar_label: 2807 Insert Greatest Common Divisors in Linked List
55
tags:
66
- Linked List
@@ -64,17 +64,17 @@ public:
6464
vector<int>a,b;
6565
ListNode* k=head;
6666
while(head!=NULL){
67-
a.push_back(head->val);
67+
a.push_back(head->val); // store each node value of the given linked list
6868
head=head->next;
6969
}
70-
for(int i=0;i<a.size()-1;i++){
70+
for(int i=0;i<a.size()-1;i++){ //to store gratest common divisors(gcd) of adjacent pairs
7171
int p=__gcd(a[i],a[i+1]);
7272
b.push_back(p);
7373
}
7474
head=k;
7575
int i=0;
76-
while(k!=NULL && k->next!=NULL){
77-
ListNode* temp=new ListNode(b[i]);
76+
while(k!=NULL && k->next!=NULL){ // inserting gcd between the linked list
77+
ListNode* temp=new ListNode(b[i]);
7878
ListNode* next=k->next;
7979
i++;
8080
k->next=temp;

0 commit comments

Comments
 (0)