File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
dsa-solutions/lc-solutions/2500 - 3000 Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change 11---
22id : 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
44sidebar_label : 2807 Insert Greatest Common Divisors in Linked List
55tags :
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;
You can’t perform that action at this time.
0 commit comments