From 69997faa1f3dc7d2aa74669730adae00019576f8 Mon Sep 17 00:00:00 2001
From: shubhangi-singh21 <shubhangifas@gmail.com>
Date: Fri, 2 Oct 2020 17:33:12 +0530
Subject: [PATCH 001/203] added bubble sort

---
 11-Some More Sorting/bubbleSort.cpp | 42 +++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 11-Some More Sorting/bubbleSort.cpp

diff --git a/11-Some More Sorting/bubbleSort.cpp b/11-Some More Sorting/bubbleSort.cpp
new file mode 100644
index 0000000..7e87a90
--- /dev/null
+++ b/11-Some More Sorting/bubbleSort.cpp	
@@ -0,0 +1,42 @@
+//Worst case time complexity: array is in decending order- log(n^2)
+
+#include <iostream>
+using namespace std;
+
+int BubbleSort( int A [20], int n)
+{
+  int i, j, temp;
+  for (i = 1; i < n; i++)
+  {
+    for (j = 0; j < n-1; j++)
+    {
+      if (A [j] > A [j+1])
+      {
+        temp = A [j];
+        A [j] = A [j + 1];
+        A [j + 1] = temp;
+      }
+    }
+  }
+  cout << "The sorted array is: ";
+  for (i = 0; i < n; i++)
+  {
+    cout << A [i] <<" ";
+  }
+}
+
+int main ()
+{
+  int A [20], i, n;
+  cout << "Enter the number of total elements of array:";
+  cin >> n;
+  cout << "\nEnter the array elements:\n";
+  for (i =0; i < n; i ++)
+  {
+    cin >> A [i];
+  }
+  cout << endl;
+  
+  BubbleSort( A, n );
+  return 0;
+}

From 9a1aba75cbdb54701e07e20457043608c510cc86 Mon Sep 17 00:00:00 2001
From: Abhijeet Sonkar <abhijeet.iiita.iib@gmail.com>
Date: Fri, 2 Oct 2020 19:58:27 +0530
Subject: [PATCH 002/203] Added solution to 76. Minimum Window Substring

---
 ONLINE JUDGE/LeetCode/76.cpp | 92 ++++++++++++++++++++++++++++++++++++
 1 file changed, 92 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/76.cpp

diff --git a/ONLINE JUDGE/LeetCode/76.cpp b/ONLINE JUDGE/LeetCode/76.cpp
new file mode 100644
index 0000000..e884189
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/76.cpp	
@@ -0,0 +1,92 @@
+#include <bits/stdc++.h>
+using namespace std;
+#define ll long long int
+const ll mod = 1e9 + 7;
+
+void init()
+{
+}
+
+void solve()
+{
+    string s;
+    string t;
+    cin >> s >> t;
+    int flag = 0;
+    int lenT = t.length();
+    int lenC = t.length();
+    int startIndex = 0;
+    int lastIndex = 0;
+    map<char, int> freq;
+    int f = INT_MAX;
+    int ansIndex = 0;
+    map<char, int> isPresent;
+    for (int i = 0; i < lenT; i++)
+    {
+        isPresent[t[i]]++;
+    }
+    if (s.find(t) != string::npos)
+    {
+        cout << t<<endl;
+        flag = 1;
+    }
+   
+    else if (!flag)
+    {
+        for (int i = 0; i < s.length(); i++)
+        {
+            if (isPresent[s[i]])
+            {
+                if (!freq[s[i]])
+                {
+                    --lenC;
+                    freq[s[i]]=i;
+                    if (lenC == lenT - 1)
+                    {
+                        startIndex = i;
+                    }
+                    else if (lenC == 0)
+                    {
+
+                        if (i - startIndex < f)
+                        {
+                            f = i - startIndex;
+                            ansIndex = startIndex;
+                        }
+                        lenC = lenT-1;
+                        startIndex = i;
+                        for (int i = 0; i < lenT; i++)
+                        {
+                            freq[t[i]] = 0;
+                        }
+                        freq[t[i]]=1;
+                    }
+                }
+            }
+        }
+        for (int i = ansIndex; i < ansIndex + f + 1; i++)
+        {
+            cout << s[i];
+            flag = 1;
+        }
+        cout << endl;
+    }
+    else if (!flag)
+    {
+        cout << "" << endl;
+    }
+}
+
+int main()
+{
+    init();
+    int t;
+    cin >> t;
+    while (t)
+    {
+        solve();
+        --t;
+    }
+
+    return 0;
+}
\ No newline at end of file

From f574c5027ee1d54d26c38451a676bd12e8f88032 Mon Sep 17 00:00:00 2001
From: snehastar <snehashuklastar1011@gmail.com>
Date: Fri, 2 Oct 2020 20:32:09 +0530
Subject: [PATCH 003/203] added rotate array file

---
 03-Arrays/rotatearr.txt | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
 create mode 100644 03-Arrays/rotatearr.txt

diff --git a/03-Arrays/rotatearr.txt b/03-Arrays/rotatearr.txt
new file mode 100644
index 0000000..028c3e5
--- /dev/null
+++ b/03-Arrays/rotatearr.txt
@@ -0,0 +1,33 @@
+#include<bits/stdc++.h>
+using namespace std;
+
+int main() {
+	int T;
+  cin>>T;
+  while(T--){
+        int n,r;
+        cin>>n;
+        cin>>r;
+        int arr[n];
+        
+        for(int i=0;i<n;i++){
+            cin>>arr[i];
+        }
+        
+        int arr1[n];
+        for(int i=0, k=r;i<n-r+1;i++,k++){
+            arr1[i]=arr[k];
+        }
+        
+        for(int i=n-r,j=0;j<r;i++,j++){
+            arr1[i]=arr[j];
+        }
+        
+        for(int i=0;i<n;i++){
+            cout<<arr1[i]<<" ";
+        }
+        cout<<endl;
+  }
+	return 0;
+
+}

From 623e623c6914b64d6b0ed306e5dd2cfd56867dad Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Fri, 2 Oct 2020 21:04:00 +0530
Subject: [PATCH 004/203] Demo Repo

---
 ONLINE JUDGE/LeetCode/#148-Sort_the_list.cpp | 51 ++++++++++++++++++++
 1 file changed, 51 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#148-Sort_the_list.cpp

diff --git a/ONLINE JUDGE/LeetCode/#148-Sort_the_list.cpp b/ONLINE JUDGE/LeetCode/#148-Sort_the_list.cpp
new file mode 100644
index 0000000..5f0f2b5
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#148-Sort_the_list.cpp	
@@ -0,0 +1,51 @@
+/**
+ * Definition for singly-linked list.
+ * struct ListNode {
+ *     int val;
+ *     ListNode *next;
+ *     ListNode() : val(0), next(nullptr) {}
+ *     ListNode(int x) : val(x), next(nullptr) {}
+ *     ListNode(int x, ListNode *next) : val(x), next(next) {}
+ * };
+ */
+class Solution {
+public:
+    ListNode* sortList(ListNode* head) {
+        if(head==NULL or head->next==NULL){
+            return head;
+        }
+        ListNode*slow=head;
+        ListNode*fast= head->next;
+        while(fast!=NULL and fast->next!=NULL){
+            slow= slow->next;
+            fast= fast->next->next;
+        }
+        ListNode*mid= slow->next;
+        slow->next= NULL;
+        ListNode*left= sortList(head);
+        ListNode*right= sortList(mid);
+        return mergeSortListNode(left,right);
+    }
+    ListNode*mergeSortListNode(ListNode*l1, ListNode*l2){
+        ListNode dummy(0);
+        ListNode*curr= &dummy;
+        while(l1!=NULL and l2!=NULL){
+            if(l1->val<l2->val){
+                curr->next= l1;
+                l1=l1->next;
+            }
+            else{
+                curr->next=l2;
+                l2= l2->next;
+            }
+            curr= curr->next;
+        }
+        if(l1!=NULL){
+            curr->next= l1;
+        }
+        else{
+            curr->next= l2;
+        }
+        return dummy.next;
+    }
+};
\ No newline at end of file

From 29808e7bcba657f59248ad79cec27c33948fefd0 Mon Sep 17 00:00:00 2001
From: n0r01tk <nikhil.revankar@walmartlabs.com>
Date: Fri, 2 Oct 2020 21:09:42 +0530
Subject: [PATCH 005/203] cpp pgm to find longest common contiguous subarray
 sum using DP

---
 .../longestCommonContiguousSubarray.cpp       | 37 +++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 24- Dynamic Programming/longestCommonContiguousSubarray.cpp

diff --git a/24- Dynamic Programming/longestCommonContiguousSubarray.cpp b/24- Dynamic Programming/longestCommonContiguousSubarray.cpp
new file mode 100644
index 0000000..554d7d3
--- /dev/null
+++ b/24- Dynamic Programming/longestCommonContiguousSubarray.cpp	
@@ -0,0 +1,37 @@
+#include<iostream> 
+#include<climits> 
+using namespace std; 
+  
+int maxSubArraySum(int a[], int size) 
+{ 
+    int max_so_far = INT_MIN, max_ending_here = 0; 
+  
+    for (int i = 0; i < size; i++) 
+    { 
+        max_ending_here = max_ending_here + a[i]; 
+        if (max_so_far < max_ending_here) 
+            max_so_far = max_ending_here; 
+  
+        if (max_ending_here < 0) 
+            max_ending_here = 0; 
+    } 
+    return max_so_far; 
+} 
+  
+/*Driver program to test maxSubArraySum*/
+int main() 
+{ 
+    int n;
+    
+    cin>>n;
+    
+    int arr[n];
+    for (int i = 0; i < n; ++i)
+    {
+        cin>>arr[i];
+    }
+    
+    int max_sum = maxSubArraySum(arr, n); 
+    cout << "Maximum contiguous sum is " << max_sum; 
+    return 0; 
+}
\ No newline at end of file

From 748307d91d554c0e3b236dfa2141a80e99479c3b Mon Sep 17 00:00:00 2001
From: Abhijeet Sonkar <abhijeet.iiita.iib@gmail.com>
Date: Fri, 2 Oct 2020 21:13:28 +0530
Subject: [PATCH 006/203] Updated 76.cpp

---
 ONLINE JUDGE/LeetCode/76.cpp | 134 ++++++++++++-----------------------
 1 file changed, 47 insertions(+), 87 deletions(-)

diff --git a/ONLINE JUDGE/LeetCode/76.cpp b/ONLINE JUDGE/LeetCode/76.cpp
index e884189..8c0948e 100644
--- a/ONLINE JUDGE/LeetCode/76.cpp	
+++ b/ONLINE JUDGE/LeetCode/76.cpp	
@@ -1,92 +1,52 @@
-#include <bits/stdc++.h>
-using namespace std;
-#define ll long long int
-const ll mod = 1e9 + 7;
-
-void init()
-{
-}
-
-void solve()
-{
-    string s;
-    string t;
-    cin >> s >> t;
-    int flag = 0;
-    int lenT = t.length();
-    int lenC = t.length();
-    int startIndex = 0;
-    int lastIndex = 0;
-    map<char, int> freq;
-    int f = INT_MAX;
-    int ansIndex = 0;
-    map<char, int> isPresent;
-    for (int i = 0; i < lenT; i++)
-    {
-        isPresent[t[i]]++;
-    }
-    if (s.find(t) != string::npos)
-    {
-        cout << t<<endl;
-        flag = 1;
-    }
-   
-    else if (!flag)
-    {
-        for (int i = 0; i < s.length(); i++)
-        {
-            if (isPresent[s[i]])
-            {
-                if (!freq[s[i]])
-                {
-                    --lenC;
-                    freq[s[i]]=i;
-                    if (lenC == lenT - 1)
-                    {
-                        startIndex = i;
-                    }
-                    else if (lenC == 0)
-                    {
+class Solution {
+public:    
+    string minWindow(string s, string t) {
+        unordered_map<char, int> table;
+        
+        // initialize frequency table for t
+        for(char c : t){
+            table[c]++;
+        }
+        
+        // initialize sliding window
+        int begin = 0, end = 0;
+        int counter = table.size();
+        int len = INT_MAX;
+        
+        string ans = "";
+        
+        // start sliding window
+        while(end < s.length()){
+            char endchar = s[end];
+            
+            // if current char found in table, decrement count
+            if(table.find(endchar) != table.end()){
+                table[endchar]--;
+                if(table[endchar] == 0) counter--;
+            }
+            
+            end++;
+            
 
-                        if (i - startIndex < f)
-                        {
-                            f = i - startIndex;
-                            ansIndex = startIndex;
-                        }
-                        lenC = lenT-1;
-                        startIndex = i;
-                        for (int i = 0; i < lenT; i++)
-                        {
-                            freq[t[i]] = 0;
-                        }
-                        freq[t[i]]=1;
-                    }
+            while(counter == 0){
+                // store new answer if smaller than previously best
+                if(end-begin < len){
+                    len = end - begin;
+                    ans = s.substr(begin, end - begin); 
                 }
+                
+ 
+                int startchar = s[begin];
+                
+                if(table.count(startchar) == 1){
+                   table[startchar]++;
+                   if(table[startchar] > 0) counter++; 
+                }
+                
+                begin++;
             }
         }
-        for (int i = ansIndex; i < ansIndex + f + 1; i++)
-        {
-            cout << s[i];
-            flag = 1;
-        }
-        cout << endl;
-    }
-    else if (!flag)
-    {
-        cout << "" << endl;
+        
+        return ans;
     }
-}
-
-int main()
-{
-    init();
-    int t;
-    cin >> t;
-    while (t)
-    {
-        solve();
-        --t;
-    }
-
-    return 0;
-}
\ No newline at end of file
+};

From 23b1ef398ec4b041580b9ac93dff5db32f98c87e Mon Sep 17 00:00:00 2001
From: shubhangi-singh21 <shubhangifas@gmail.com>
Date: Fri, 2 Oct 2020 21:20:01 +0530
Subject: [PATCH 007/203] added a binary tree program

---
 18-Binary Tree/isBinary_BST.cpp | 72 +++++++++++++++++++++++++++++++++
 1 file changed, 72 insertions(+)
 create mode 100644 18-Binary Tree/isBinary_BST.cpp

diff --git a/18-Binary Tree/isBinary_BST.cpp b/18-Binary Tree/isBinary_BST.cpp
new file mode 100644
index 0000000..b9b6c02
--- /dev/null
+++ b/18-Binary Tree/isBinary_BST.cpp	
@@ -0,0 +1,72 @@
+/* A program to check if a binary tree is BST or not */
+
+
+#include<bits/stdc++.h> 
+  
+using namespace std; 
+  
+class node  
+{  
+    public: 
+    int data;  
+    node* left;  
+    node* right;  
+      
+    /* Constructor*/
+
+    node(int data) 
+    { 
+        this->data = data; 
+        this->left = NULL; 
+        this->right = NULL; 
+    } 
+}; 
+  
+int isBSTUtil(node* node, int min, int max);  
+  
+/* Returns true if the given  
+tree is a binary search tree  
+(efficient version). */
+int isBST(node* node)  
+{  
+    return(isBSTUtil(node, INT_MIN, INT_MAX));  
+}  
+  
+/* Returns true if the given 
+tree is a BST and its values 
+are >= min and <= max. */
+int isBSTUtil(node* node, int min, int max)  
+{  
+    /* an empty tree is BST */
+    if (node==NULL)  
+        return 1;  
+              
+    /* false if this node violates 
+    the min/max constraint */
+    if (node->data < min || node->data > max)  
+        return 0;  
+      
+    /* otherwise check the subtrees recursively,  
+    tightening the min or max constraint */
+    return
+        isBSTUtil(node->left, min, node->data-1) &&   
+        isBSTUtil(node->right, node->data+1, max);   
+}  
+  
+  
+int main()  
+{  
+    node *root = new node(4);  
+    root->left = new node(2);  
+    root->right = new node(5);  
+    root->left->left = new node(1);  
+    root->left->right = new node(3);  
+      
+    if(isBST(root))  
+        cout<<"Is a BST";  
+    else
+        cout<<"Not a BST";  
+          
+    return 0;  
+}  
+  

From f0f04561b97be50b6670e4f095bedba033694e38 Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Fri, 2 Oct 2020 21:31:05 +0530
Subject: [PATCH 008/203] Delete bubbleSort.cpp

---
 11-Some More Sorting/bubbleSort.cpp | 42 -----------------------------
 1 file changed, 42 deletions(-)
 delete mode 100644 11-Some More Sorting/bubbleSort.cpp

diff --git a/11-Some More Sorting/bubbleSort.cpp b/11-Some More Sorting/bubbleSort.cpp
deleted file mode 100644
index 7e87a90..0000000
--- a/11-Some More Sorting/bubbleSort.cpp	
+++ /dev/null
@@ -1,42 +0,0 @@
-//Worst case time complexity: array is in decending order- log(n^2)
-
-#include <iostream>
-using namespace std;
-
-int BubbleSort( int A [20], int n)
-{
-  int i, j, temp;
-  for (i = 1; i < n; i++)
-  {
-    for (j = 0; j < n-1; j++)
-    {
-      if (A [j] > A [j+1])
-      {
-        temp = A [j];
-        A [j] = A [j + 1];
-        A [j + 1] = temp;
-      }
-    }
-  }
-  cout << "The sorted array is: ";
-  for (i = 0; i < n; i++)
-  {
-    cout << A [i] <<" ";
-  }
-}
-
-int main ()
-{
-  int A [20], i, n;
-  cout << "Enter the number of total elements of array:";
-  cin >> n;
-  cout << "\nEnter the array elements:\n";
-  for (i =0; i < n; i ++)
-  {
-    cin >> A [i];
-  }
-  cout << endl;
-  
-  BubbleSort( A, n );
-  return 0;
-}

From 2e9b108061b4990e10c6f10271f4b5109a7b3629 Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Fri, 2 Oct 2020 21:37:22 +0530
Subject: [PATCH 009/203] Add files via upload

---
 ONLINE JUDGE/LeetCode/#2 Add-two-numbers.cpp | 36 ++++++++++++++++++++
 1 file changed, 36 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#2 Add-two-numbers.cpp

diff --git a/ONLINE JUDGE/LeetCode/#2 Add-two-numbers.cpp b/ONLINE JUDGE/LeetCode/#2 Add-two-numbers.cpp
new file mode 100644
index 0000000..4f2a6f1
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#2 Add-two-numbers.cpp	
@@ -0,0 +1,36 @@
+/**
+ * Definition for singly-linked list.
+ * struct ListNode {
+ *     int val;
+ *     ListNode *next;
+ *     ListNode() : val(0), next(nullptr) {}
+ *     ListNode(int x) : val(x), next(nullptr) {}
+ *     ListNode(int x, ListNode *next) : val(x), next(next) {}
+ * };
+ */
+class Solution {
+public:
+    ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) {
+        ListNode*temp= new ListNode(-1);
+        ListNode*curr= temp;
+        int carry=0;
+        while(l1 or l2){
+            int n1= l1?l1->val:0;
+            int n2= l2?l2->val:0;
+            int sum= n1+n2+ carry;
+            carry= sum/10;
+            curr->next= new ListNode(sum%10);
+            curr= curr->next;
+            if(l1){
+                l1= l1->next;
+            }
+            if(l2){
+                l2= l2->next;
+            }
+            if(carry){
+                curr->next= new ListNode(carry);
+            }
+        }
+        return temp->next;
+    }
+};
\ No newline at end of file

From fd825ccde6a86e307dc31f2f7edce50366712ec8 Mon Sep 17 00:00:00 2001
From: Nikhil3698 <54366846+Nikhil3698@users.noreply.github.com>
Date: Fri, 2 Oct 2020 22:35:08 +0530
Subject: [PATCH 010/203] LCA problem

Program To find Lowest Common Ancestor Of a Binary Tree.
---
 ...owest_Common_Ancestor_of_a_Binary_Tree.cpp | 26 +++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#236-Lowest_Common_Ancestor_of_a_Binary_Tree.cpp

diff --git a/ONLINE JUDGE/LeetCode/#236-Lowest_Common_Ancestor_of_a_Binary_Tree.cpp b/ONLINE JUDGE/LeetCode/#236-Lowest_Common_Ancestor_of_a_Binary_Tree.cpp
new file mode 100644
index 0000000..c72a574
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#236-Lowest_Common_Ancestor_of_a_Binary_Tree.cpp	
@@ -0,0 +1,26 @@
+/**
+ * Definition for a binary tree node.
+ * struct TreeNode {
+ *     int val;
+ *     TreeNode *left;
+ *     TreeNode *right;
+ *     TreeNode(int x) : val(x), left(NULL), right(NULL) {}
+ * };
+ */
+class Solution {
+public:
+    TreeNode* lowestCommonAncestor(TreeNode* root, TreeNode* p, TreeNode* q) {
+        if(root==p or root==q or !root)
+            return root;
+        
+        TreeNode* left=lowestCommonAncestor(root->left,p,q);
+        TreeNode* right=lowestCommonAncestor(root->right,p,q);
+        
+        if(!right)
+            return left;
+        if(!left)
+            return right;
+            
+       return root;     
+    }
+};
\ No newline at end of file

From 4bef2dc1f753f825032cc15a59296b51811b30c9 Mon Sep 17 00:00:00 2001
From: snehastar <snehashuklastar1011@gmail.com>
Date: Sat, 3 Oct 2020 00:30:04 +0530
Subject: [PATCH 011/203]  find duplicates in array

---
 03-Arrays/duplicate_arr.cpp | 41 +++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
 create mode 100644 03-Arrays/duplicate_arr.cpp

diff --git a/03-Arrays/duplicate_arr.cpp b/03-Arrays/duplicate_arr.cpp
new file mode 100644
index 0000000..708e5f9
--- /dev/null
+++ b/03-Arrays/duplicate_arr.cpp
@@ -0,0 +1,41 @@
+#include <bits/stdc++.h>
+using namespace std;
+vector<int> duplicates(int arr[], int n);//function to check the duplicates
+int main() {
+    int t;//number of testcases
+    cin >> t;
+    while (t-- > 0) {
+        int n;//n is lenght of array
+        cin >> n;
+        int a[n];
+        for (int i = 0; i < n; i++) cin >> a[i];
+        vector<int> ans = duplicates(a, n);
+        for (int i : ans) cout << i << ' ';
+        cout << endl;
+    }
+    return 0;
+}
+
+vector<int> duplicates(int arr[], int n) {
+vector<int> v;
+    sort(arr,arr+n); //sorting the array
+    int i=0;
+    int j;
+    while(i<n-1){
+        j=i+1;
+	//if array element and next elements are same then duplicate is present and we push in the vector
+        if(arr[j]==arr[i])
+            v.push_back(arr[i]);
+	//till the array elements are same we don't do anything
+        while(arr[i]==arr[j])
+            j++;
+        i=j;
+    }
+    //if no duplicate elements are present then outputis -1
+    if(v.empty())
+        v.push_back(-1);
+    return v;
+    }
+
+
+

From 273ede005191e4837169345d7a6d0ca33f19fddf Mon Sep 17 00:00:00 2001
From: snehastar <snehashuklastar1011@gmail.com>
Date: Sat, 3 Oct 2020 00:37:41 +0530
Subject: [PATCH 012/203] push zeroes to right

---
 03-Arrays/zeros_arr.cpp | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100644 03-Arrays/zeros_arr.cpp

diff --git a/03-Arrays/zeros_arr.cpp b/03-Arrays/zeros_arr.cpp
new file mode 100644
index 0000000..5d6ce47
--- /dev/null
+++ b/03-Arrays/zeros_arr.cpp
@@ -0,0 +1,32 @@
+//C++ program to push all the zeroes to the right side of the array keeping the order of non zero numbers same
+
+#include<bits/stdc++.h>
+using namespace std;
+
+int main() {
+    //t is the number of testcases
+    int t;
+    cin>>t;
+    while(t--){ 
+        int n; // n is the length of the array
+        cin>>n;
+        int arr[n]; // this array is for taking array inputs from user
+        int arr2[n]; // this array is to store the non zero elements in their order
+        for(int i=0;i<n;i++){
+            arr2[i]=0; // it is first completely filled with zeroes
+        }
+	// algo for making arr2
+        for(int i=0,j=0;i<n;i++){
+            cin>>arr[i];
+            if(arr[i]>0){
+                arr2[j]=arr[i];
+                j++;}
+        }
+	//printing out the arr2 values
+        for(int i=0;i<n;i++){
+            cout<<arr2[i]<<" ";
+        }
+        cout<<endl;
+    }
+	return 0;
+}

From b5ef970d1133fa7cb15eb9d196983878179222eb Mon Sep 17 00:00:00 2001
From: Nikhil3698 <54366846+Nikhil3698@users.noreply.github.com>
Date: Sat, 3 Oct 2020 00:49:24 +0530
Subject: [PATCH 013/203] Inversion Of Binary Tree

Problem to Invert a Binary Tree.
---
 .../LeetCode/#226-Invert_Binary_Tree.cpp      | 23 +++++++++++++++++++
 1 file changed, 23 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#226-Invert_Binary_Tree.cpp

diff --git a/ONLINE JUDGE/LeetCode/#226-Invert_Binary_Tree.cpp b/ONLINE JUDGE/LeetCode/#226-Invert_Binary_Tree.cpp
new file mode 100644
index 0000000..dd0f7e2
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#226-Invert_Binary_Tree.cpp	
@@ -0,0 +1,23 @@
+/**
+ * Definition for a binary tree node.
+ * struct TreeNode {
+ *     int val;
+ *     TreeNode *left;
+ *     TreeNode *right;
+ *     TreeNode() : val(0), left(nullptr), right(nullptr) {}
+ *     TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
+ *     TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
+ * };
+ */
+class Solution {
+public:
+    TreeNode* invertTree(TreeNode* root) {
+        if(!root)
+            return NULL;
+        
+        swap(root->left,root->right);
+        invertTree(root->left);
+        invertTree(root->right);
+        return root;
+    }
+};
\ No newline at end of file

From 55f97bb0170e42d2d4cbcb6b1d29852c363ea181 Mon Sep 17 00:00:00 2001
From: snehastar <snehashuklastar1011@gmail.com>
Date: Sat, 3 Oct 2020 00:52:06 +0530
Subject: [PATCH 014/203] check palindrome in LL

---
 13- Linked Lists/palindrome_ll.cpp | 97 ++++++++++++++++++++++++++++++
 1 file changed, 97 insertions(+)
 create mode 100644 13- Linked Lists/palindrome_ll.cpp

diff --git a/13- Linked Lists/palindrome_ll.cpp b/13- Linked Lists/palindrome_ll.cpp
new file mode 100644
index 0000000..7a3c716
--- /dev/null
+++ b/13- Linked Lists/palindrome_ll.cpp	
@@ -0,0 +1,97 @@
+// in this program we check if the given LL is a palindrome or not and return 1 for Palindrome and 0 for not palindrome
+#include <iostream>
+#include <stack>
+using namespace std;
+
+// linked list structure
+struct Node {
+  int data;
+  struct Node *next;
+  Node(int x) {
+    data = x;
+    next = NULL;
+  }
+};
+
+
+// function to check given linked list is palindrome or not
+bool isPalindrome(Node *head, int n);
+
+int main()
+{
+  int T,i,n,l,firstdata;
+    cin>>T;
+    while(T--)
+    {
+        
+        struct Node *head = NULL,  *tail = NULL;
+        cin>>n;
+        // taking first data of LL
+        cin>>firstdata;
+        head = new Node(firstdata);
+        tail = head;
+        // taking remaining data of LL
+        for(i=1;i<n;i++)
+        {
+            cin>>l;
+            tail->next = new Node(l);
+            tail = tail->next;
+        }
+   	cout<<isPalindrome(head,n)<<endl;
+    }
+    return 0;
+}
+
+
+bool isPalindrome(Node *head, int n)
+{
+    //initialize all the pointers
+    Node* temp=head;
+    Node* tempcount=head;
+    Node* r=head;
+    Node* p=NULL;
+    Node* q=NULL;
+   
+    //if only 1 element is present
+    if(n==1) 
+        return 1;
+    
+    //if only 2 elements are present
+    if(n==2){
+        if(temp->data!=temp->next->data)
+            return 0;
+        else
+            return 1;
+    }
+    
+    //for any number of elements present in LL
+    int new_count=n/2;
+    while(new_count>0){
+        r=r->next;
+        new_count--;
+    }
+    
+    while(r != NULL){
+        p=q;
+        q=r;
+        r=r->next;
+        q->next=p;
+    }
+    
+    int a = n/2;
+    while(a>1){
+        if(q->data!=temp->data){
+            return 0;
+            break;
+        }
+        q=q->next;
+        temp=temp->next;
+        a--;
+    }
+    if(q->data==temp->data)
+        return 1;
+    else
+        return 0;
+}
+
+

From 2bb6ea9c99f5bc278d686e14b46bcdd65ebefe45 Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Sat, 3 Oct 2020 11:06:19 +0530
Subject: [PATCH 015/203] Rename Contributing.md to CONTRIBUTING.md

---
 Contributing.md => CONTRIBUTING.md | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename Contributing.md => CONTRIBUTING.md (100%)

diff --git a/Contributing.md b/CONTRIBUTING.md
similarity index 100%
rename from Contributing.md
rename to CONTRIBUTING.md

From ca76c7b291c118e5807d5ec8f3a5eb6ae9fa1561 Mon Sep 17 00:00:00 2001
From: n0r01tk <nikhil.revankar@walmartlabs.com>
Date: Sat, 3 Oct 2020 11:42:36 +0530
Subject: [PATCH 016/203] cpp pgm to implement stack in O(1) time complexity

---
 ...tack_Implementaion_O-1_time_complexity.cpp | 133 ++++++++++++++++++
 1 file changed, 133 insertions(+)
 create mode 100644 15-Stack/Stack_Implementaion_O-1_time_complexity.cpp

diff --git a/15-Stack/Stack_Implementaion_O-1_time_complexity.cpp b/15-Stack/Stack_Implementaion_O-1_time_complexity.cpp
new file mode 100644
index 0000000..fc480bd
--- /dev/null
+++ b/15-Stack/Stack_Implementaion_O-1_time_complexity.cpp
@@ -0,0 +1,133 @@
+#include <iostream> 
+#include <stdlib.h> 
+  
+using namespace std; 
+  
+/* A simple stack class with  
+basic stack funtionalities */
+class Stack { 
+private: 
+    static const int max = 100; 
+    int arr[max]; 
+    int top; 
+  
+public: 
+    Stack() { top = -1; } 
+    bool isEmpty(); 
+    bool isFull(); 
+    int pop(); 
+    void push(int x); 
+}; 
+  
+/* Stack's member method to check  
+if the stack is iempty */
+bool Stack::isEmpty() 
+{ 
+    if (top == -1) 
+        return true; 
+    return false; 
+} 
+  
+/* Stack's member method to check  
+if the stack is full */
+bool Stack::isFull() 
+{ 
+    if (top == max - 1) 
+        return true; 
+    return false; 
+} 
+  
+/* Stack's member method to remove  
+an element from it */
+int Stack::pop() 
+{ 
+    if (isEmpty()) { 
+        cout << "Stack Underflow"; 
+        abort(); 
+    } 
+    int x = arr[top]; 
+    top--; 
+    return x; 
+} 
+  
+/* Stack's member method to insert  
+an element to it */
+void Stack::push(int x) 
+{ 
+    if (isFull()) { 
+        cout << "Stack Overflow"; 
+        abort(); 
+    } 
+    top++; 
+    arr[top] = x; 
+} 
+  
+/* A class that supports all the stack  
+operations and one additional 
+  operation getMin() that returns the  
+minimum element from stack at 
+  any time.  This class inherits from  
+the stack class and uses an 
+  auxiliarry stack that holds minimum  
+elements */
+class SpecialStack : public Stack { 
+    Stack min; 
+  
+public: 
+    int pop(); 
+    void push(int x); 
+    int getMin(); 
+}; 
+  
+/* SpecialStack's member method to insert 
+ an element to it. This method 
+   makes sure that the min stack is also  
+updated with appropriate minimum 
+   values */
+void SpecialStack::push(int x) 
+{ 
+    if (isEmpty() == true) { 
+        Stack::push(x); 
+        min.push(x); 
+    } 
+    else { 
+        Stack::push(x); 
+        int y = min.pop(); 
+        min.push(y); 
+        if (x < y) 
+            min.push(x); 
+        else
+            min.push(y); 
+    } 
+} 
+  
+/* SpecialStack's member method to  
+remove an element from it. This method 
+   removes top element from min stack also. */
+int SpecialStack::pop() 
+{ 
+    int x = Stack::pop(); 
+    min.pop(); 
+    return x; 
+} 
+  
+/* SpecialStack's member method to get 
+ minimum element from it. */
+int SpecialStack::getMin() 
+{ 
+    int x = min.pop(); 
+    min.push(x); 
+    return x; 
+} 
+  
+int main() 
+{ 
+    SpecialStack s; 
+    s.push(10); 
+    s.push(20); 
+    s.push(30); 
+    cout << s.getMin() << endl; 
+    s.push(5); 
+    cout << s.getMin(); 
+    return 0; 
+}
\ No newline at end of file

From 1bdca574b0348db8df6ea4e457302968519fd044 Mon Sep 17 00:00:00 2001
From: Utkarsh Lath <utkarshlath2@gmail.com>
Date: Sat, 3 Oct 2020 11:49:48 +0530
Subject: [PATCH 017/203] Add SPOJ codes

---
 ONLINE JUDGE/SPOJ/ACODE Alphacode.cpp         | 28 +++++++
 ONLINE JUDGE/SPOJ/AGGRCOW Aggressive Cows.cpp | 56 +++++++++++++
 .../SPOJ/PALIN The next Palindrome.cpp        | 78 +++++++++++++++++++
 3 files changed, 162 insertions(+)
 create mode 100644 ONLINE JUDGE/SPOJ/ACODE Alphacode.cpp
 create mode 100644 ONLINE JUDGE/SPOJ/AGGRCOW Aggressive Cows.cpp
 create mode 100644 ONLINE JUDGE/SPOJ/PALIN The next Palindrome.cpp

diff --git a/ONLINE JUDGE/SPOJ/ACODE Alphacode.cpp b/ONLINE JUDGE/SPOJ/ACODE Alphacode.cpp
new file mode 100644
index 0000000..36ce103
--- /dev/null
+++ b/ONLINE JUDGE/SPOJ/ACODE Alphacode.cpp	
@@ -0,0 +1,28 @@
+#include<iostream>
+#include<string>
+using namespace std;
+
+int main()
+{
+    while(true)
+    {
+        string s;
+        cin>>s;
+        if((s[0])=='0')
+            break;
+        long long int memo[s.length()]={0};
+        memo[0]=1;
+        for(int i=1;i<s.length();i++)
+        {
+            if(s[i]!='0')
+                memo[i]=memo[i-1];
+            int num = ((s[i]-'0')+10*((s[i-1]-'0')));
+            if(num>=10&&num<=26&&i>1)
+                memo[i]+=memo[i-2];
+            else if(num>=10&&num<=26&&i==1)
+                memo[1]+=1;
+        }
+        cout<<memo[s.length()-1]<<endl;
+    }
+    return 0;
+}
\ No newline at end of file
diff --git a/ONLINE JUDGE/SPOJ/AGGRCOW Aggressive Cows.cpp b/ONLINE JUDGE/SPOJ/AGGRCOW Aggressive Cows.cpp
new file mode 100644
index 0000000..68f618c
--- /dev/null
+++ b/ONLINE JUDGE/SPOJ/AGGRCOW Aggressive Cows.cpp	
@@ -0,0 +1,56 @@
+#include<iostream>
+#include<vector>
+#include<algorithm>
+using namespace std;
+
+int checkDist(long long int maxdist,vector <long long int> arr, int c)
+{
+    int left=0;
+    c--;
+    for(int i=1;i<arr.size();i++)
+    {
+        if((arr[i]-arr[left])>=maxdist)
+        {
+            c--;
+            left=i;
+        }
+    }
+    if(c<=0)
+        return 1;
+    else
+        return 0;
+}
+int main()
+{
+    int t;
+    cin>>t;
+    while(t--)
+    {
+        int n,c;
+        cin>>n>>c;
+        vector <long long int> arr(n);
+        for(int i=0;i<n;i++)
+            cin>>arr[i];
+        sort(arr.begin(),arr.end());
+        int left = arr[0],right = arr[n-1];
+        long long int maxdist = left + (right-left)/2;
+        long long int ans=0;
+        while(left<=right)
+        {
+            //cout<<maxdist<<endl;
+            if(checkDist(maxdist,arr,c)==1)
+            {
+                if(maxdist>ans)
+                    ans=maxdist;
+                left=maxdist+1;
+                maxdist=left + (right-left)/2;
+            }
+            else
+            {
+                right = maxdist-1;
+                maxdist = left + (right-left)/2;
+            }
+        }
+        cout<<ans<<endl;
+    }
+}
\ No newline at end of file
diff --git a/ONLINE JUDGE/SPOJ/PALIN The next Palindrome.cpp b/ONLINE JUDGE/SPOJ/PALIN The next Palindrome.cpp
new file mode 100644
index 0000000..5fa25bd
--- /dev/null
+++ b/ONLINE JUDGE/SPOJ/PALIN The next Palindrome.cpp	
@@ -0,0 +1,78 @@
+#include<bits/stdc++.h>
+using namespace std;
+
+string allnine(string s, int len)
+{
+    string result(1, '1');
+    for(int i=1;i<=len-1;i++)
+        result+='0';
+    result += '1';
+    return result;
+}
+
+string findPalindrome(string s, int len)
+{
+    string left,right,result;
+    left = s.substr(0,len/2);
+    if(len%2!=0)
+        right = s.substr(len/2+1,len/2);
+    else
+        right = s.substr(len/2,len/2);
+    int sublen = left.length();
+    for(int i=sublen-1,j=0;i>=0,j<sublen;i--,j++)
+    {
+        if((left[i]-'0')==(right[j]-'0'))
+            continue;
+        if((left[i]-'0')>(right[j]-'0'))
+        {
+            result=left;
+            string rev(result.rbegin(),result.rend());
+            if(len%2!=0)
+                result+= s[len/2];
+            result += rev;
+            return result;
+        }
+        if((left[i]-'0')<(right[j]-'0'))
+            break;
+    }
+    int carry=0;
+    for(int i=ceil(float(len)/2)-1;i>=0;i--)
+    {
+        int x = s[i]-'0';
+        if(i==(ceil(float(len)/2)-1))
+            x=x+1;
+        if(carry)
+            x = x+carry;
+        carry = x/10;
+        x=x%10;
+        s[i]=x+'0';
+        s[len-i-1]=x+'0';
+    }
+    return s;
+}
+
+int main()
+{
+    long long int t;
+    cin>>t;
+    string one(1,'1');
+    while(t--)
+    {
+        string str,result;
+        cin>>str;
+        str.erase(0, min(str.find_first_not_of('0'), str.size()-1));
+        int flag=0,len=str.length();
+        for(int i=0;i<len;i++)
+            if(str[i]!='9')
+                flag=1;
+        if(flag==0)
+        {
+            result = allnine(str,len);
+            cout<<result<<endl;
+            continue;
+        }
+        result = findPalindrome(str,len);
+        cout<<result<<endl;
+    }
+    return 0;
+}
\ No newline at end of file

From 9f10fa293d840c576f473ea8e86803b537b2985b Mon Sep 17 00:00:00 2001
From: Utkarsh Lath <utkarshlath2@gmail.com>
Date: Sat, 3 Oct 2020 12:14:13 +0530
Subject: [PATCH 018/203] Add Matrix Rotation

---
 03-Arrays/MatrixRotation.cpp | 80 ++++++++++++++++++++++++++++++++++++
 1 file changed, 80 insertions(+)
 create mode 100644 03-Arrays/MatrixRotation.cpp

diff --git a/03-Arrays/MatrixRotation.cpp b/03-Arrays/MatrixRotation.cpp
new file mode 100644
index 0000000..6a92994
--- /dev/null
+++ b/03-Arrays/MatrixRotation.cpp
@@ -0,0 +1,80 @@
+#include<iostream>
+using namespace std;
+
+//Function to input the matrix from the user
+void inputMatrix(int matrix[][10], int row, int column)
+{
+   printf("\nEnter elements: \n");
+   for (int i = 0; i < row; ++i)
+      for (int j = 0; j < column; ++j)
+      {
+         printf("Enter a[%d][%d]: ", i + 1, j + 1);
+         cin>>matrix[i][j];
+      }
+}
+
+//Function to print a given matrix
+void printMatrix(int matrix[][10], int row, int column)
+{
+   for (int i = 0; i < row; ++i)
+        for (int j = 0; j < column; ++j)
+        {
+            printf("%d  ", matrix[i][j]);
+            if (j == column - 1)
+            printf("\n");
+        }
+}
+
+//Function to swap two integers
+void swap(int *a, int *b) 
+{ 
+    int t = *a; 
+    *a = *b; 
+    *b = t; 
+}
+
+//Function to find the transpose of a matrix
+void findTranspose(int matrix[][10], int transpose[][10],int row, int column)
+{
+    for(int i=0;i<row;i++)
+        for(int j=0;j<column;j++)
+            transpose[j][i] = matrix[i][j];
+}
+
+//Function to find the clockwise rotated matrix
+void findClockwiseMatrix(int matrix[][10], int clockwise[][10],int row, int column)
+{
+    findTranspose(matrix,clockwise,row,column);
+    for(int i=0;i<column;i++)
+        for(int j=0;j<row/2;j++)
+            swap(&clockwise[i][j], &clockwise[i][row-j-1]);            
+}
+
+//Function to find the antilcokwise rotated matrix
+void findAntiClockwiseMatrix(int matrix[][10], int aclockwise[][10],int row, int column)
+{
+    findTranspose(matrix,aclockwise,row,column);
+    for(int i=0;i<column/2;i++)
+        for(int j=0;j<row;j++)
+            swap(&aclockwise[i][j], &aclockwise[column-i-1][j]);              
+}
+
+int main()
+{
+    int matrix[10][10],clockwise[10][10],aclockwise[10][10],row,column;
+
+    printf("\nEnter the row and column values: ");
+    cin>>row>>column;
+
+    inputMatrix(matrix,row,column); 
+    //Function to find out the clockwise rotated matrix
+    findClockwiseMatrix(matrix,clockwise,row,column); 
+    //Function to find out the anticlockwise rotated matrix
+    findAntiClockwiseMatrix(matrix,aclockwise,row,column);  
+
+    printf("\nMatrix rotated by 90 degree clockwise: \n");
+    printMatrix(clockwise,column,row);
+
+    printf("\nMatrix rotated by 90 degree anticlockwise: \n");
+    printMatrix(aclockwise,column,row);
+}
\ No newline at end of file

From 584d947e9b5627a085ad91f7fc3478d67410bb8e Mon Sep 17 00:00:00 2001
From: Utkarsh Lath <utkarshlath2@gmail.com>
Date: Sat, 3 Oct 2020 12:19:56 +0530
Subject: [PATCH 019/203] Add SPOJ Files

---
 .../GSS1 Can you answer these queries I.cpp   |  92 ++++++++++++++++
 .../SPOJ/HORRIBLE Horrible Queries.cpp        | 102 ++++++++++++++++++
 ONLINE JUDGE/SPOJ/INVCNT Inversion Count.cpp  |  66 ++++++++++++
 ONLINE JUDGE/SPOJ/JULKA Julka.cpp             | 101 +++++++++++++++++
 ONLINE JUDGE/SPOJ/PRIME1 Prime Generator.cpp  |  29 +++++
 5 files changed, 390 insertions(+)
 create mode 100644 ONLINE JUDGE/SPOJ/GSS1 Can you answer these queries I.cpp
 create mode 100644 ONLINE JUDGE/SPOJ/HORRIBLE Horrible Queries.cpp
 create mode 100644 ONLINE JUDGE/SPOJ/INVCNT Inversion Count.cpp
 create mode 100644 ONLINE JUDGE/SPOJ/JULKA Julka.cpp
 create mode 100644 ONLINE JUDGE/SPOJ/PRIME1 Prime Generator.cpp

diff --git a/ONLINE JUDGE/SPOJ/GSS1 Can you answer these queries I.cpp b/ONLINE JUDGE/SPOJ/GSS1 Can you answer these queries I.cpp
new file mode 100644
index 0000000..5e0ddd8
--- /dev/null
+++ b/ONLINE JUDGE/SPOJ/GSS1 Can you answer these queries I.cpp	
@@ -0,0 +1,92 @@
+#include<bits/stdc++.h>
+using namespace std;
+#define inf 0x3f3f 
+
+struct Node { 
+    int maxPrefixSum; 
+    int maxSuffixSum; 
+    int totalSum; 
+    int maxSubarraySum; 
+   
+    Node() 
+    { 
+        maxPrefixSum = maxSuffixSum = maxSubarraySum = -inf; 
+        totalSum = -inf; 
+    } 
+};
+Node merge(Node left, Node right)
+{
+    Node parent;
+    parent.maxPrefixSum = max(left.maxPrefixSum,left.totalSum+right.maxPrefixSum);
+    parent.maxSuffixSum = max(right.maxSuffixSum, right.totalSum+left.maxSuffixSum);
+    parent.totalSum = left.totalSum+right.totalSum;
+    parent.maxSubarraySum = max({left.maxSubarraySum,right.maxSubarraySum,left.maxSuffixSum+right.maxPrefixSum});
+    return parent;
+}
+void construct_tree_util(Node*tree, int arr[], int low, int high, int pos)
+{
+    if(low==high)
+    {
+        tree[pos].maxPrefixSum=arr[low];
+        tree[pos].maxSuffixSum=arr[low];
+        tree[pos].totalSum=arr[low];
+        tree[pos].maxSubarraySum=arr[low];
+        return;
+    }
+    int mid = (low+high)/2;
+    construct_tree_util(tree,arr,low,mid,2*pos);
+    construct_tree_util(tree,arr, mid+1,high,2*pos+1);
+    tree[pos] = merge(tree[2*pos],tree[2*pos+1]);
+}
+Node* construct_tree(int arr[],int n)
+{
+    
+    int seglen;
+    if((ceil(log2(n))==floor(log2(n))))
+        seglen = n*2-1;
+    else
+        seglen = pow(2,(ceil(log2(n))))*2-1;
+    Node* tree = new Node[seglen];
+    construct_tree_util(tree,arr,0,n-1,1);
+    return tree;
+}
+
+Node solveQueryUtil(Node*tree, int low, int high, int qlow, int qhigh, int pos)
+{
+    if(high<qlow||qhigh<low)
+    {
+        Node nullnode;
+        return nullnode;
+    }
+    if(low>=qlow&&qhigh>=high)
+        return tree[pos];
+    int mid = (low + high)/2; 
+    Node left = solveQueryUtil(tree, low, mid, qlow, qhigh, 2*pos); 
+    Node right = solveQueryUtil(tree, mid + 1, high, qlow, qhigh, 2*pos + 1);  
+    Node res = merge(left, right); 
+    return res; 
+}
+int solveQuery(Node* tree, int low, int high, int n)
+{
+    Node res = solveQueryUtil(tree, 0, n - 1, low, high, 1); 
+    return res.maxSubarraySum; 
+}
+
+int main()
+{
+    int n;
+    cin>>n;
+    int arr[n];
+    for(int i=0;i<n;i++)
+        cin>>arr[i];
+    Node* tree = construct_tree(arr,n);
+    int m;
+    cin>>m;
+    while(m--)
+    {
+        int x,y;
+        cin>>x>>y;
+        cout<<solveQuery(tree,x-1,y-1,n)<<endl;
+    }
+    return 0;
+}
\ No newline at end of file
diff --git a/ONLINE JUDGE/SPOJ/HORRIBLE Horrible Queries.cpp b/ONLINE JUDGE/SPOJ/HORRIBLE Horrible Queries.cpp
new file mode 100644
index 0000000..ba96767
--- /dev/null
+++ b/ONLINE JUDGE/SPOJ/HORRIBLE Horrible Queries.cpp	
@@ -0,0 +1,102 @@
+#include<bits/stdc++.h>
+using namespace std;
+
+long long int tree[400001]={0};
+long long int lazy[400001]={0};
+
+void updateRange(long long int ss, long long int se, long long int us, long long int ue, long long int diff, long long int si)
+{
+    if(lazy[si]!=0)
+    {
+        tree[si] += (se-ss+1)*lazy[si];
+        if(se!=ss)
+        {
+            lazy[2*si+1]+=lazy[si];
+            lazy[2*si+2]+=lazy[si];
+        }
+        lazy[si]=0;
+    }
+    if(ss>se||ss>ue||se<us)
+        return;
+    if(us<=ss&&ue>=se)
+    {
+        tree[si]+= (se-ss+1)*diff;
+        if(ss!=se)
+        {
+            lazy[2*si+1] += diff;
+            lazy[2*si+2] += diff; 
+        }
+        return;
+    }
+    long long int mid = ss + (se-ss)/2;
+    updateRange(ss,mid,us,ue,diff,2*si+1);
+    updateRange(mid+1,se,us,ue,diff,2*si+2);
+    tree[si] = tree[2*si+1]+tree[2*si+2];
+}
+long long int getSum(long long int ss, long long int se, long long int qs, long long int qe, long long int si)
+{
+    if(lazy[si]!=0)
+    {
+        tree[si] += (se-ss+1)*lazy[si];
+        if(se!=ss)
+        {
+            lazy[2*si+1]+=lazy[si];
+            lazy[2*si+2]+=lazy[si];
+        }
+        lazy[si]=0;
+    }
+    if(ss>se||ss>qe||se<qs)
+        return 0;
+    if(qs<=ss&&qe>=se)
+        return tree[si];
+    long long int mid = ss + (se-ss)/2;
+    return getSum(ss,mid,qs,qe,2*si+1)+getSum(mid+1,se,qs,qe,2*si+2);
+}
+void constructTreeUtil(long long int arr[], long long int ss, long long int se, long long int si)
+{
+    if(ss>se)
+        return;
+    if(ss==se)
+    {
+        tree[si]=arr[ss];
+        return;
+    }
+    long long int mid = ss + (se-ss)/2;
+    constructTreeUtil(arr,ss,mid,2*si+1);
+    constructTreeUtil(arr,mid+1,se,2*si+2);
+    tree[si] = tree[2*si+1]+tree[2*si+2];
+}
+void constructTree(long long int arr[], long long int n)
+{
+    constructTreeUtil(arr,0,n-1,0);
+}
+int main()
+{
+    long long int t;
+    cin>>t;
+    while(t--)
+    {
+        long long int n,c;
+        cin>>n>>c;
+        long long int arr[n] = {0};
+        memset(tree,0,sizeof(tree));
+        memset(lazy,0,sizeof(tree));
+        constructTree(arr,n);
+        for(long long int i=0;i<c;i++)
+        {
+            long long int flag,p,q,v;
+            cin>>flag;
+            if(flag==0)
+            {
+                cin>>p>>q>>v;
+                updateRange(0,n-1,p-1,q-1,v,0);
+            }
+            else
+            {
+                cin>>p>>q;
+                cout<<getSum(0,n-1,p-1,q-1,0)<<endl;
+            }   
+        }
+    }
+    return 0;
+}
\ No newline at end of file
diff --git a/ONLINE JUDGE/SPOJ/INVCNT Inversion Count.cpp b/ONLINE JUDGE/SPOJ/INVCNT Inversion Count.cpp
new file mode 100644
index 0000000..2fce06f
--- /dev/null
+++ b/ONLINE JUDGE/SPOJ/INVCNT Inversion Count.cpp	
@@ -0,0 +1,66 @@
+#include<iostream>
+#include<vector>
+using namespace std;
+typedef long long int LL;
+
+LL merge(vector<LL> &arr, vector<LL> &temp, LL l, LL m, LL r)
+{
+    LL i=l,j=m,k=l,inv=0;
+    //vector<LL> temp(arr.size());
+    while(i<m&&j<=r)
+    {
+        if(arr[i]<arr[j])
+            temp[k++]=arr[i++];
+        else if(arr[i]==arr[j])
+        {
+            temp[k++]=arr[i++];
+            j++;
+        }
+        else
+        {
+            temp[k++]=arr[j++];
+            inv += (m-i);
+        }
+
+    }
+    while(i<m)
+        temp[k++]=arr[i++];
+    while(j<=r)
+        temp[k++]=arr[j++];
+    for(LL p=l;p<=r;p++)
+        arr[p]=temp[p];
+    return inv;
+}
+LL mergesort(vector<LL> &arr,vector<LL> &temp, LL l, LL r)
+{
+    LL inv=0;
+    if(l<r)
+    {
+        LL mid = (l+r)/2;
+        inv += mergesort(arr,temp,l,mid);
+        inv += mergesort(arr,temp,mid+1,r);
+        inv += merge(arr,temp,l,mid+1,r);
+    }
+    return inv;
+}
+LL _mergesort(vector<LL> arr,LL n)
+{
+    vector<LL> temp(n);
+    return mergesort(arr,temp,0,n-1);
+}
+int main()
+{
+    LL t;
+    cin>>t;
+    while(t--)
+    {
+        LL n;
+        cin>>n;
+        vector<LL> arr(n);
+        for(LL i=0;i<n;i++)
+            cin>>arr[i];
+        LL inv = _mergesort(arr,n);
+        cout<<inv<<endl;
+    }
+    return 0;
+}
\ No newline at end of file
diff --git a/ONLINE JUDGE/SPOJ/JULKA Julka.cpp b/ONLINE JUDGE/SPOJ/JULKA Julka.cpp
new file mode 100644
index 0000000..7d56bc8
--- /dev/null
+++ b/ONLINE JUDGE/SPOJ/JULKA Julka.cpp	
@@ -0,0 +1,101 @@
+#include<bits/stdc++.h>
+using namespace std;
+
+string findDiff(string str1, string str2) 
+{ 
+    string str = ""; 
+    int n1 = str1.length(), n2 = str2.length(); 
+    int diff = n1 - n2;  
+    int carry = 0; 
+  
+    for (int i=n2-1; i>=0; i--) 
+    { 
+        int sub = ((str1[i+diff]-'0') - (str2[i]-'0') - carry); 
+        if (sub < 0) 
+        { 
+            sub = sub+10; 
+            carry = 1; 
+        } 
+        else
+            carry = 0; 
+  
+        str.push_back(sub + '0'); 
+    } 
+    for (int i=n1-n2-1; i>=0; i--) 
+    { 
+        if (str1[i]=='0' && carry) 
+        { 
+            str.push_back('9'); 
+            continue; 
+        } 
+        int sub = ((str1[i]-'0') - carry); 
+        if (i>0 || sub>0)
+            str.push_back(sub+'0'); 
+        carry = 0; 
+  
+    } 
+    reverse(str.begin(), str.end()); 
+    return str; 
+} 
+ 
+string findSum(string str1, string str2) 
+{ 
+    string str = ""; 
+    if (str1.length() > str2.length()) 
+        swap(str1, str2); 
+    int n1 = str1.length(), n2 = str2.length(); 
+
+    reverse(str1.begin(), str1.end()); 
+    reverse(str2.begin(), str2.end()); 
+  
+    int carry = 0; 
+    for (int i=0; i<n1; i++) 
+    { 
+        int sum = ((str1[i]-'0')+(str2[i]-'0')+carry); 
+        str.push_back(sum%10 + '0'); 
+        carry = sum/10; 
+    } 
+  
+    for (int i=n1; i<n2; i++) 
+    { 
+        int sum = ((str2[i]-'0')+carry); 
+        str.push_back(sum%10 + '0'); 
+        carry = sum/10; 
+    } 
+  
+    if (carry) 
+        str.push_back(carry+'0'); 
+ 
+    reverse(str.begin(), str.end()); 
+  
+    return str; 
+}
+string longDivision(string number, int divisor) 
+{ 
+    string ans; 
+    int idx = 0; 
+    int temp = number[idx] - '0'; 
+    while (temp < divisor) 
+        temp = temp * 10 + (number[++idx] - '0'); 
+  
+    while (number.size() > idx) { 
+        ans += (temp / divisor) + '0'; 
+        temp = (temp % divisor) * 10 + number[++idx] - '0'; 
+    } 
+    if (ans.length() == 0) 
+        return "0"; 
+    return ans; 
+}
+int main()
+{
+    int t=10;
+    while(t--)
+    {
+        string a,b,x,y;
+        cin>>a>>b;
+        x=findSum(a,b);
+        y=findDiff(a,b);
+        cout<<longDivision(x,2)<<endl<<longDivision(y,2)<<endl;
+    }
+    return 0;
+}
\ No newline at end of file
diff --git a/ONLINE JUDGE/SPOJ/PRIME1 Prime Generator.cpp b/ONLINE JUDGE/SPOJ/PRIME1 Prime Generator.cpp
new file mode 100644
index 0000000..03c5147
--- /dev/null
+++ b/ONLINE JUDGE/SPOJ/PRIME1 Prime Generator.cpp	
@@ -0,0 +1,29 @@
+#include<iostream>
+#include<cmath>
+using namespace std;
+
+int main()
+{
+    int t;
+    cin>>t;
+    while(t--)
+    {
+        long int m,n;
+        cin>>m>>n;
+        for(int i=m;i<=n;i++)
+        {   
+            int flag=0;
+            for(int j=2;j<=sqrt(i);j++)
+            {
+                if(i%j==0)
+                {
+                    flag=1;
+                    break;
+                }
+            }
+            if(!flag&&i>=2)
+                cout<<i<<endl;
+        }
+    }
+    cout<<endl;
+}
\ No newline at end of file

From 174969a19f0b65dc8b9a3d2be4203d6fad7690d3 Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Sat, 3 Oct 2020 12:29:40 +0530
Subject: [PATCH 020/203] Add files via upload

---
 ONLINE JUDGE/LeetCode/#328 Odd-Even-List.cpp | 29 ++++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#328 Odd-Even-List.cpp

diff --git a/ONLINE JUDGE/LeetCode/#328 Odd-Even-List.cpp b/ONLINE JUDGE/LeetCode/#328 Odd-Even-List.cpp
new file mode 100644
index 0000000..ab840df
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#328 Odd-Even-List.cpp	
@@ -0,0 +1,29 @@
+/**
+ * Definition for singly-linked list.
+ * struct ListNode {
+ *     int val;
+ *     ListNode *next;
+ *     ListNode() : val(0), next(nullptr) {}
+ *     ListNode(int x) : val(x), next(nullptr) {}
+ *     ListNode(int x, ListNode *next) : val(x), next(next) {}
+ * };
+ */
+class Solution {
+public:
+    ListNode* oddEvenList(ListNode* head) {
+        if(head==NULL){
+            return NULL;
+        }
+        ListNode*oddIndex= head;
+        ListNode*evenIndex= head->next;
+        ListNode*evenHead=evenIndex;
+        while(evenIndex!=NULL and evenIndex->next!=NULL){
+            oddIndex->next= evenIndex->next;
+            oddIndex=oddIndex->next;
+            evenIndex->next= oddIndex->next;
+            evenIndex= evenIndex->next;
+        }
+        oddIndex->next= evenHead;
+        return head;
+    }
+};
\ No newline at end of file

From 6180c20d69339ead5683d9cdec54e1bf6d15cf37 Mon Sep 17 00:00:00 2001
From: Akshansh Rewariya <akshanshrewariya@gmail.com>
Date: Sat, 3 Oct 2020 17:52:27 +0530
Subject: [PATCH 021/203]  #200 added

---
 .../LeetCode/#200-Number-of-Islands.cpp       | 39 +++++++++++++++++++
 1 file changed, 39 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#200-Number-of-Islands.cpp

diff --git a/ONLINE JUDGE/LeetCode/#200-Number-of-Islands.cpp b/ONLINE JUDGE/LeetCode/#200-Number-of-Islands.cpp
new file mode 100644
index 0000000..9105f84
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#200-Number-of-Islands.cpp	
@@ -0,0 +1,39 @@
+class Solution {
+public:
+    
+    int dfs(int i,int j,int n, int m, vector <vector <char>>& g){
+        //Conditions to check for
+        if(i<0||j<0||i>n-1||j>m-1||g[i][j]=='0') return 0;
+        
+        //value of g here as 0 so no further dfs calls are made 
+        g[i][j]='0';
+        
+        //DFS calls in all four directions
+        dfs(i-1,j,n,m,g);
+        dfs(i+1,j,n,m,g);
+        dfs(i,j+1,n,m,g);
+        dfs(i,j-1,n,m,g);
+        
+        return 1;
+    }
+    
+    int numIslands(vector<vector<char>>& grid) {
+
+        if(grid.empty()==true) return 0;
+        
+        //Answer Variable
+        int ans=0;
+        int n=grid.size(); //rows
+        int m=grid[0].size(); //columns
+
+        for(int i=0;i<n;i++){
+            for(int j=0;j<m;j++){
+                if(grid[i][j]=='1'){ //we check for 1 in grid and call dfs on the matrix
+                    ans+=dfs(i,j,n,m,grid);
+                }
+            }
+        }
+        
+        return ans;
+    }
+};
\ No newline at end of file

From 838a2d4d6abe524b2be5ad85f6bd76ea565f3096 Mon Sep 17 00:00:00 2001
From: Manikanth <65079433+alpha-neutr0n@users.noreply.github.com>
Date: Sat, 3 Oct 2020 18:02:42 +0530
Subject: [PATCH 022/203] Create trap_rain_water.cpp

---
 .../trap_rain_water.cpp                       | 33 +++++++++++++++++++
 1 file changed, 33 insertions(+)
 create mode 100644 10- Recursion & Backtracking/trap_rain_water.cpp

diff --git a/10- Recursion & Backtracking/trap_rain_water.cpp b/10- Recursion & Backtracking/trap_rain_water.cpp
new file mode 100644
index 0000000..2343d00
--- /dev/null
+++ b/10- Recursion & Backtracking/trap_rain_water.cpp	
@@ -0,0 +1,33 @@
+//Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.
+
+class Solution
+{
+public:
+    int trap(vector<int>& height)
+    {
+        if (height.size() < 3) { return 0; }
+        
+        // Get the indices of two highest bars, sort them and put into top2bars
+        array<vector<int>::iterator, 2> top2bars;
+        top2bars[0] = max_element(height.begin(), height.end());
+        int tmp = *(top2bars[0]);
+        *(top2bars[0]) = INT_MIN;
+        top2bars[1] = max_element(height.begin(), height.end());
+		int top2bars_min = *(top2bars[1]); 
+        *(top2bars[0]) = tmp;
+        sort(top2bars.begin(), top2bars.end());
+        
+		// Calculate the amount of water between the two highest bars
+        int output = 0;  // amount of trapped water
+        for (auto it = top2bars[0] + 1; it < top2bars[1]; ++it)
+        {
+            output += top2bars_min - *it;
+        }
+        
+		// Call recursively trap() on bars left and right to the top2bars and add to the output
+        vector<int>&& left = {height.begin(), top2bars[0] + 1};
+        vector<int>&& right = {top2bars[1], height.end()};
+            
+        return output + trap(left) + trap(right);
+    }
+};

From e01cedc344e07d82818517b1db8a8a338b1bdd27 Mon Sep 17 00:00:00 2001
From: ordaboy <t.samat01@gmail.com>
Date: Sat, 3 Oct 2020 17:58:55 +0500
Subject: [PATCH 023/203] 36. Valid Sudoku Solution in cpp

---
 ONLINE JUDGE/LeetCode/#36 Valid Sudoku.cpp | 35 ++++++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#36 Valid Sudoku.cpp

diff --git a/ONLINE JUDGE/LeetCode/#36 Valid Sudoku.cpp b/ONLINE JUDGE/LeetCode/#36 Valid Sudoku.cpp
new file mode 100644
index 0000000..12f6d99
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#36 Valid Sudoku.cpp	
@@ -0,0 +1,35 @@
+class Solution {
+public:
+    bool isValidSudoku(vector<vector<char>>& board) {
+        vector<array<bool,9>> rows(9);
+        vector<array<bool,9>> cols(9);
+        vector<array<bool,9>> squares(9);
+                    
+        for (int y = 0; y < 9 ; ++y)  {
+            for (int x = 0; x < 9; ++x) {
+                if (board[y][x] == '.') continue;
+                
+                const int current = board[y][x] - '1';
+                
+                if (rows[y][current]) {
+                   return false; 
+                } else {
+                   rows[y][current] = 1;
+                }
+                if (cols[x][current]) {
+                   return false; 
+                } else {
+                   cols[x][current] = 1 ;
+                }
+                
+                const int sq_index = (y / 3) * 3 + x / 3;
+                if (squares[sq_index][current]) {
+                    return false;     
+                } else {
+                    squares[sq_index][current] = 1 ;
+                }
+            }
+        }
+        return true;
+    }
+};

From 3bcd2882aec864006e1c2973ad0ad9d6e3a19e74 Mon Sep 17 00:00:00 2001
From: Koulick <ks2202@it.jgec.ac.in>
Date: Sat, 3 Oct 2020 19:08:33 +0530
Subject: [PATCH 024/203] Added Leetcode Three Consecutive Odds.cpp

---
 .../LeetCode/#1550:Three-Consecutive-Odds.cpp | 33 +++++++++++++++++++
 1 file changed, 33 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#1550:Three-Consecutive-Odds.cpp

diff --git a/ONLINE JUDGE/LeetCode/#1550:Three-Consecutive-Odds.cpp b/ONLINE JUDGE/LeetCode/#1550:Three-Consecutive-Odds.cpp
new file mode 100644
index 0000000..afc4f96
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#1550:Three-Consecutive-Odds.cpp	
@@ -0,0 +1,33 @@
+#include<bits/stdc++.h>
+#include<string.h>
+#define ll long long int
+#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
+#define pb push_back
+#define endl "\n"
+using namespace std;
+bool threeConsecutiveOdds(vector<int>& arr) {
+        bool flag=false;
+        for(int i=1;i<arr.size()-1;i++){
+            if(arr[i]&1 and arr[i-1]&1 and arr[i+1]&1){
+                flag=true;
+                break;
+            }
+        }
+        return flag;
+}
+void solve(){
+    //input
+    int n;
+    cin>>n;
+    vector<int>arr(n);
+    for(int i=0;i<n;i++){
+		cin>>arr[i];
+    }
+    cout<<threeConsecutiveOdds(arr);
+}
+int main()
+{
+    fio;
+    solve();
+}
+ 

From a4cc45475ae0ee719909d5cbe7cf69b1dbbea102 Mon Sep 17 00:00:00 2001
From: Nikola Grujic <nikola-grujic@hotmail.com>
Date: Sat, 3 Oct 2020 15:50:45 +0200
Subject: [PATCH 025/203] Added solution to Codechef problem PSHTTR

---
 .../PSHTTR Pishty and tree.cpp                | 122 ++++++++++++++++++
 1 file changed, 122 insertions(+)
 create mode 100644 ONLINE JUDGE/CodeChef Challenges/PSHTTR Pishty and tree.cpp

diff --git a/ONLINE JUDGE/CodeChef Challenges/PSHTTR Pishty and tree.cpp b/ONLINE JUDGE/CodeChef Challenges/PSHTTR Pishty and tree.cpp
new file mode 100644
index 0000000..f7759cc
--- /dev/null
+++ b/ONLINE JUDGE/CodeChef Challenges/PSHTTR Pishty and tree.cpp	
@@ -0,0 +1,122 @@
+// Solution for problem Pishty and Tree (PSHTTR) using Persistent Segment Tree
+// Author: @nikolatechie
+
+#include <bits/stdc++.h>
+using namespace std;
+
+struct Node
+{
+    int val;
+    Node *c[2];
+
+    Node(int v = 0, Node *l = nullptr, Node *r = nullptr)
+    {
+        val = v;
+        c[0] = l;
+        c[1] = r;
+    }
+};
+
+const int N = 1e5 + 5;
+const int VAL = 1e9 + 5;
+Node *root[N];
+int n;
+vector <pair <int,int>> g[N];
+
+void Update(Node *oldRoot, Node *&newRoot, int sl, int sr, int pos)
+{
+    newRoot = new Node();
+
+    if (sl == sr)
+    {
+        newRoot->val ^= sl;
+        if (oldRoot != nullptr) newRoot->val ^= oldRoot->val;
+        return;
+    }
+
+    int mid = (sl+sr)>>1;
+    Node *L = nullptr, *R = nullptr;
+    if (oldRoot != nullptr) L = oldRoot->c[0], R = oldRoot->c[1];
+
+    if (pos <= mid)
+    {
+        newRoot->c[1] = R;
+        Update(L, newRoot->c[0], sl, mid, pos);
+    }
+    else
+    {
+        newRoot->c[0] = L;
+        Update(R, newRoot->c[1], mid+1, sr, pos);
+    }
+
+    L = newRoot->c[0], R = newRoot->c[1];
+    if (L != nullptr) newRoot->val ^= L->val;
+    if (R != nullptr) newRoot->val ^= R->val;
+}
+
+int Query(Node *&x, int sl, int sr, ci &l, ci &r)
+{
+    if (x == nullptr || l > r || sl > r || sr < l) return 0;
+    if (sl >= l && sr <= r) return x->val;
+
+    int mid = (sl+sr)>>1;
+
+    return Query(x->c[0], sl, mid, l, r) ^
+        Query(x->c[1], mid+1, sr, l, r);
+}
+
+void DFS(int node, int p)
+{
+    for (const auto &it: g[node])
+    {
+        int ngb = it.first, cost = it.second;
+        if (ngb == node || ngb == p) continue;
+        Update(root[node], root[ngb], 1, VAL, cost);
+        DFS(ngb, node);
+    }
+}
+
+int main()
+{
+    ios_base::sync_with_stdio(0);
+    cin.tie(0);
+
+
+    int TC;
+    cin >> TC;
+
+    while (TC)
+    {
+        --TC;
+        cin >> n;
+
+        for (int t1 = 1; t1 <= n; ++t1)
+        {
+            g[t1].clear();
+            root[t1] = nullptr;
+        }
+
+        for (int t1 = 1; t1 < n; ++t1)
+        {
+            int a, b, w;
+            cin >> a >> b >> w;
+            g[a].push_back({b, w});
+            g[b].push_back({a, w});
+        }
+
+        DFS(1, -1);
+        int q;
+        cin >> q;
+
+        while (q)
+        {
+            --q;
+            int a, b, k;
+            cin >> a >> b >> k;
+            cout << (Query(root[a], 1, VAL, 1, k) ^
+                    Query(root[b], 1, VAL, 1, k)) << '\n';
+        }
+    }
+
+    return 0;
+}
\ No newline at end of file

From 6b254138df2658143eaedbb6e152648d9cc0ab12 Mon Sep 17 00:00:00 2001
From: Mohit saha <52305250+mohitsaha@users.noreply.github.com>
Date: Sat, 3 Oct 2020 19:23:17 +0530
Subject: [PATCH 026/203] #62 unique paths

frequently asked dp problem
---
 ONLINE JUDGE/LeetCode/#62-Unique-Paths.cpp | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#62-Unique-Paths.cpp

diff --git a/ONLINE JUDGE/LeetCode/#62-Unique-Paths.cpp b/ONLINE JUDGE/LeetCode/#62-Unique-Paths.cpp
new file mode 100644
index 0000000..479bc41
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#62-Unique-Paths.cpp	
@@ -0,0 +1,21 @@
+class Solution {
+public:
+    int uniquePaths(int m, int n) {
+        int dp[m][n];
+        for(int i=0;i<n;i++){
+            dp[0][i]=1;
+        }
+        
+        for(int i=1;i<m;i++){
+            dp[i][0]=1;
+        }
+        
+        for(int i=1;i<m;i++){
+            for(int j=1;j<n;j++){
+                dp[i][j]=dp[i-1][j]+dp[i][j-1];
+            }
+        }
+        
+        return dp[m-1][n-1];
+    }
+};

From a3f2019ff8103a12a13e2ca37c735e36f6533a7d Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Sat, 3 Oct 2020 20:08:27 +0530
Subject: [PATCH 027/203] Update pull_request_template.md

---
 .github/pull_request_template.md | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md
index 5325acf..e113e8d 100644
--- a/.github/pull_request_template.md
+++ b/.github/pull_request_template.md
@@ -1,11 +1,11 @@
-** Added the <Filename> Filename **
+** Added the <Filename> Filename as**
 
 
 ** Changes Proposed <Describe> in the PR Describe
 
+
 ** I am assuring that the file is not redundant and making the Pull Request **
 - [ ] Yes
-- [ ] No
  
  Read {% include Contributing.md %}
 

From cbe08eab4531d06f47725292b0708979297c2bb7 Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Sat, 3 Oct 2020 20:14:09 +0530
Subject: [PATCH 028/203] Update CONTRIBUTING.md

---
 CONTRIBUTING.md | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 8fe2d57..1bf3c14 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -14,6 +14,14 @@ We expect everyone to follow the code of conduct
 anywhere in thoughtbot's project codebases,
 issue trackers, chatrooms, and mailing lists.
 
+# Pull Request Instructions
+ - Instead of Creating a new Branch. Fork the Repo and Update Your contribution to the related files or Repo.
+ - Try to add the Algorithm or Program in files respectively.
+ - You can add new content only Related to C++ Programming
+ - Create a PR with subjective Title. This will help me to organize the content in better way.
+ - Try to Update the .gitignore if you're adding different formats of content.
+ - Create a PR :bowtie:
+
 ## Contributing Code
   - Fork the repo.
 

From 65583556fdd624080983cd2a9d3791caf2347724 Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Sat, 3 Oct 2020 20:14:42 +0530
Subject: [PATCH 029/203] Update CONTRIBUTING.md

---
 CONTRIBUTING.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 1bf3c14..fbbf18d 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -17,7 +17,7 @@ issue trackers, chatrooms, and mailing lists.
 # Pull Request Instructions
  - Instead of Creating a new Branch. Fork the Repo and Update Your contribution to the related files or Repo.
  - Try to add the Algorithm or Program in files respectively.
- - You can add new content only Related to C++ Programming
+ - You can add new content only **Related to C++ Programming**
  - Create a PR with subjective Title. This will help me to organize the content in better way.
  - Try to Update the .gitignore if you're adding different formats of content.
  - Create a PR :bowtie:

From ffc2543bec277284d2e7f4c1fff1e31dd61a9e8b Mon Sep 17 00:00:00 2001
From: Devansh Markan <500069794@stu.upes.ac.in>
Date: Sat, 3 Oct 2020 20:46:15 +0530
Subject: [PATCH 030/203] Create #33-Accessing Inherited Functions.cpp

---
 .../#33-Accessing Inherited Functions.cpp     | 41 +++++++++++++++++++
 1 file changed, 41 insertions(+)
 create mode 100644 ONLINE JUDGE/Hackerrank/#33-Accessing Inherited Functions.cpp

diff --git a/ONLINE JUDGE/Hackerrank/#33-Accessing Inherited Functions.cpp b/ONLINE JUDGE/Hackerrank/#33-Accessing Inherited Functions.cpp
new file mode 100644
index 0000000..f9da198
--- /dev/null
+++ b/ONLINE JUDGE/Hackerrank/#33-Accessing Inherited Functions.cpp	
@@ -0,0 +1,41 @@
+
+
+class D:public A,public B,public C 
+{
+
+	int val;
+	public:
+		//Initially val is 1
+		 D()
+		 {
+		 	val = 1;
+		 }
+
+
+		 //Implement this function
+		 
+           void update_val(int new_val)
+{
+    int a = new_val;
+     while ( a %2 == 0)
+     {
+         a = a/2;
+         A::func(val);
+     }
+     while ( a % 3 == 0)
+     {
+         a = a/3;
+         B::func(val);
+     }
+     while ( a % 5 == 0)
+     {
+         a = a/5;
+         C::func(val);
+     }
+} 
+			
+		 
+		 //For Checking Purpose
+		 void check(int); //Do not delete this line.
+};
+

From b9d01c0dbdae65ccc5323cfc30d436fd5359cc09 Mon Sep 17 00:00:00 2001
From: ordaboy <t.samat01@gmail.com>
Date: Sun, 4 Oct 2020 00:39:57 +0500
Subject: [PATCH 031/203] Added 1503 and 319 problems on Leetcode

---
 ...t-Moment-Before-All-Ants-Fall-Out-Of-A-Plank.cpp | 13 +++++++++++++
 ONLINE JUDGE/LeetCode/#319 Bulb Switcher.cpp        |  6 ++++++
 2 files changed, 19 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#1503 Last-Moment-Before-All-Ants-Fall-Out-Of-A-Plank.cpp
 create mode 100644 ONLINE JUDGE/LeetCode/#319 Bulb Switcher.cpp

diff --git a/ONLINE JUDGE/LeetCode/#1503 Last-Moment-Before-All-Ants-Fall-Out-Of-A-Plank.cpp b/ONLINE JUDGE/LeetCode/#1503 Last-Moment-Before-All-Ants-Fall-Out-Of-A-Plank.cpp
new file mode 100644
index 0000000..f955801
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#1503 Last-Moment-Before-All-Ants-Fall-Out-Of-A-Plank.cpp	
@@ -0,0 +1,13 @@
+class Solution {
+public:
+    int getLastMoment(int n, vector<int>& left, vector<int>& right) {
+        int minLeft = INT_MAX, maxRight = INT_MIN;
+        for(int num : right) {
+            minLeft = min(num, minLeft);
+        }
+        for(int num : left) {
+            maxRight = max(maxRight, num);
+        }
+        return max(n - minLeft, maxRight);
+    }
+};
diff --git a/ONLINE JUDGE/LeetCode/#319 Bulb Switcher.cpp b/ONLINE JUDGE/LeetCode/#319 Bulb Switcher.cpp
new file mode 100644
index 0000000..1a84daf
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#319 Bulb Switcher.cpp	
@@ -0,0 +1,6 @@
+class Solution {
+public:
+    int bulbSwitch(int n) {
+        return sqrt(n);
+    }
+};

From 4151a83ac56f135cd0a07bcf4b2c78ee7c9a024c Mon Sep 17 00:00:00 2001
From: Priyanshi Sharma <priyanshi417@gmail.com>
Date: Sun, 4 Oct 2020 03:31:50 +0530
Subject: [PATCH 032/203] Create #733-Flood_Fill.cpp

---
 ONLINE JUDGE/LeetCode/#733-Flood_Fill.cpp | 45 +++++++++++++++++++++++
 1 file changed, 45 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#733-Flood_Fill.cpp

diff --git a/ONLINE JUDGE/LeetCode/#733-Flood_Fill.cpp b/ONLINE JUDGE/LeetCode/#733-Flood_Fill.cpp
new file mode 100644
index 0000000..f7544d4
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#733-Flood_Fill.cpp	
@@ -0,0 +1,45 @@
+class Solution {
+public:
+    
+    bool isValid(vector<vector<int>>& image, int row , int column)
+    {
+        if((row<0||row>=image.size()||column<0||column>=image[0].size()))
+           return false;
+          
+         return true;
+    }
+           
+    void call(vector<vector<int>>& image, int r, int c, int OldColour, int newColor )
+           {
+               if(!isValid(image,r,c))
+                   return;
+               
+               if(image[r][c]!=OldColour)
+                   return;
+               
+               //image[r][c]=newColor;
+               floodFill(image, r,c,newColor);
+           }
+    vector<vector<int>> floodFill(vector<vector<int>>& image, int sr, int sc, int newColor) {
+        
+        
+        if(!isValid(image,sr,sc))
+            return image;
+        
+        
+        int OldColour = image[sr][sc];
+        
+        if(OldColour==newColor)
+            return image;
+        
+        image[sr][sc] = newColor;
+        call(image, sr-1,sc,OldColour, newColor);
+        call(image, sr+1,sc,OldColour, newColor);
+      
+        call(image, sr,sc-1,OldColour, newColor);
+        call(image, sr,sc+1,OldColour, newColor);
+        
+        
+        return image;
+    }
+};

From cf467e4641dff32c9538d42829aa69b0546a3d74 Mon Sep 17 00:00:00 2001
From: Priyanshi Sharma <priyanshi417@gmail.com>
Date: Sun, 4 Oct 2020 03:32:51 +0530
Subject: [PATCH 033/203] Create #200-Number_of_Islands.cpp

---
 .../LeetCode/#200-Number_of_Islands.cpp       | 40 +++++++++++++++++++
 1 file changed, 40 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#200-Number_of_Islands.cpp

diff --git a/ONLINE JUDGE/LeetCode/#200-Number_of_Islands.cpp b/ONLINE JUDGE/LeetCode/#200-Number_of_Islands.cpp
new file mode 100644
index 0000000..1a24713
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#200-Number_of_Islands.cpp	
@@ -0,0 +1,40 @@
+class Solution {
+public:
+    
+    void colourit(vector<vector<char>> & grid,int r, int c, char colour)
+    {
+        if(r<0||r>=grid.size()||c<0||c>=grid[0].size())
+            return;
+        
+        if(grid[r][c]=='1')
+        {
+            grid[r][c] = colour;
+            colourit(grid,r+1,c,colour);
+            colourit(grid,r-1,c,colour);
+            colourit(grid,r,c+1,colour);
+            colourit(grid,r,c-1,colour);     
+        }
+    }
+    int numIslands(vector<vector<char>>& grid) {
+        
+      
+        char ch = 'a';
+        int ctr = 0;
+        for(int i=0;i<grid.size();i++)
+        {
+            for(int j=0;j<grid[0].size();j++)
+            {
+                if(grid[i][j]=='1')
+                {
+                    colourit(grid,i,j,ch);
+                    ch++;
+                    ctr++;
+                }   
+            }
+        }
+        
+       // int d = ch-'a';
+        return ctr;
+        
+    }
+};

From 2cb1232cad7d74e773472be51dbdef52c679e781 Mon Sep 17 00:00:00 2001
From: Priyanshi Sharma <priyanshi417@gmail.com>
Date: Sun, 4 Oct 2020 03:33:06 +0530
Subject: [PATCH 034/203] Delete #200-Number_of_Islands.cpp

---
 .../LeetCode/#200-Number_of_Islands.cpp       | 40 -------------------
 1 file changed, 40 deletions(-)
 delete mode 100644 ONLINE JUDGE/LeetCode/#200-Number_of_Islands.cpp

diff --git a/ONLINE JUDGE/LeetCode/#200-Number_of_Islands.cpp b/ONLINE JUDGE/LeetCode/#200-Number_of_Islands.cpp
deleted file mode 100644
index 1a24713..0000000
--- a/ONLINE JUDGE/LeetCode/#200-Number_of_Islands.cpp	
+++ /dev/null
@@ -1,40 +0,0 @@
-class Solution {
-public:
-    
-    void colourit(vector<vector<char>> & grid,int r, int c, char colour)
-    {
-        if(r<0||r>=grid.size()||c<0||c>=grid[0].size())
-            return;
-        
-        if(grid[r][c]=='1')
-        {
-            grid[r][c] = colour;
-            colourit(grid,r+1,c,colour);
-            colourit(grid,r-1,c,colour);
-            colourit(grid,r,c+1,colour);
-            colourit(grid,r,c-1,colour);     
-        }
-    }
-    int numIslands(vector<vector<char>>& grid) {
-        
-      
-        char ch = 'a';
-        int ctr = 0;
-        for(int i=0;i<grid.size();i++)
-        {
-            for(int j=0;j<grid[0].size();j++)
-            {
-                if(grid[i][j]=='1')
-                {
-                    colourit(grid,i,j,ch);
-                    ch++;
-                    ctr++;
-                }   
-            }
-        }
-        
-       // int d = ch-'a';
-        return ctr;
-        
-    }
-};

From 59e7704bfffa23c27e1aaa8d27e58a1211b0c9f4 Mon Sep 17 00:00:00 2001
From: Priyanshi Sharma <priyanshi417@gmail.com>
Date: Sun, 4 Oct 2020 03:34:12 +0530
Subject: [PATCH 035/203] Create #49-Group_anagrams.cpp

---
 ONLINE JUDGE/LeetCode/#49-Group_anagrams.cpp | 24 ++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#49-Group_anagrams.cpp

diff --git a/ONLINE JUDGE/LeetCode/#49-Group_anagrams.cpp b/ONLINE JUDGE/LeetCode/#49-Group_anagrams.cpp
new file mode 100644
index 0000000..dd42360
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#49-Group_anagrams.cpp	
@@ -0,0 +1,24 @@
+class Solution {
+public:
+    vector<vector<string>> groupAnagrams(vector<string>& strs) {
+        
+        vector<vector<string> > ret;
+        map<vector<int>,vector<string>> group;
+        
+        for(int i = 0; i<strs.size();i++)
+        {
+            vector<int> word(26,0);
+            for(int j = 0; j<strs[i].size();j++)
+            {
+                word[strs[i][j] - 'a']++;
+            }
+            group[word].push_back(strs[i]);
+        }
+        
+        for(auto itr : group)
+            ret.push_back(itr.second);
+        
+        return ret;
+  
+    }
+};

From 64e903c47180e226794007c6f9fe6ebb417b9419 Mon Sep 17 00:00:00 2001
From: Priyanshi Sharma <priyanshi417@gmail.com>
Date: Sun, 4 Oct 2020 03:35:36 +0530
Subject: [PATCH 036/203] Create #1-Two_Sum.cpp

---
 ONLINE JUDGE/LeetCode/#1-Two_Sum.cpp | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#1-Two_Sum.cpp

diff --git a/ONLINE JUDGE/LeetCode/#1-Two_Sum.cpp b/ONLINE JUDGE/LeetCode/#1-Two_Sum.cpp
new file mode 100644
index 0000000..629539c
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#1-Two_Sum.cpp	
@@ -0,0 +1,18 @@
+class Solution {
+public:
+    vector<int> twoSum(vector<int>& nums, int target) {
+        
+        map<int,int> vals;
+
+        for(int i=0;i<nums.size();i++)
+        {
+            if(vals.find(target - nums[i])!=vals.end()&&vals[target - nums[i]]!=i)
+                return {i,vals[target - nums[i]]};
+            else
+                vals[nums[i]] = i;
+                
+        }
+        
+        return {};
+    }
+};

From 1c34087a938738c6598bf597476e10e9467efa74 Mon Sep 17 00:00:00 2001
From: Priyanshi Sharma <priyanshi417@gmail.com>
Date: Sun, 4 Oct 2020 03:36:34 +0530
Subject: [PATCH 037/203] Create #3-Longest substring without reapeating
 characters.cpp

---
 ...ubstring without reapeating characters.cpp | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#3-Longest substring without reapeating characters.cpp

diff --git a/ONLINE JUDGE/LeetCode/#3-Longest substring without reapeating characters.cpp b/ONLINE JUDGE/LeetCode/#3-Longest substring without reapeating characters.cpp
new file mode 100644
index 0000000..40ebce8
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#3-Longest substring without reapeating characters.cpp	
@@ -0,0 +1,19 @@
+class Solution {
+public:
+    int lengthOfLongestSubstring(string s) {
+      map<char, int> Mp;
+        int start = -1;
+        int len = 0;
+        
+        for(int i=0; i< s.size(); i++){
+            if(Mp.count(s[i]) != 0)
+            {
+                start = max(start, Mp[s[i]]);
+            }
+            Mp[s[i]] = i;
+            len = max(len, i-start);
+            cout<<start<<' '<<Mp[s[i]]<<' '<<len<<endl;
+        }
+        return len;
+    }
+};

From 0be1e78dfb23c57c0b6c91ee9a42567ecdb368f2 Mon Sep 17 00:00:00 2001
From: Priyanshi Sharma <priyanshi417@gmail.com>
Date: Sun, 4 Oct 2020 03:36:57 +0530
Subject: [PATCH 038/203] Update #3-Longest substring without reapeating
 characters.cpp

---
 .../#3-Longest substring without reapeating characters.cpp       | 1 -
 1 file changed, 1 deletion(-)

diff --git a/ONLINE JUDGE/LeetCode/#3-Longest substring without reapeating characters.cpp b/ONLINE JUDGE/LeetCode/#3-Longest substring without reapeating characters.cpp
index 40ebce8..195da94 100644
--- a/ONLINE JUDGE/LeetCode/#3-Longest substring without reapeating characters.cpp	
+++ b/ONLINE JUDGE/LeetCode/#3-Longest substring without reapeating characters.cpp	
@@ -12,7 +12,6 @@ class Solution {
             }
             Mp[s[i]] = i;
             len = max(len, i-start);
-            cout<<start<<' '<<Mp[s[i]]<<' '<<len<<endl;
         }
         return len;
     }

From 06d468ecc4cf3978b663f803d46f07f3b5e0c0d9 Mon Sep 17 00:00:00 2001
From: Priyanshi Sharma <priyanshi417@gmail.com>
Date: Sun, 4 Oct 2020 03:38:33 +0530
Subject: [PATCH 039/203] Create #8 - String to Integer (atoi).cpp

---
 .../#8 - String to Integer (atoi).cpp         | 62 +++++++++++++++++++
 1 file changed, 62 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#8 - String to Integer (atoi).cpp

diff --git a/ONLINE JUDGE/LeetCode/#8 - String to Integer (atoi).cpp b/ONLINE JUDGE/LeetCode/#8 - String to Integer (atoi).cpp
new file mode 100644
index 0000000..a3baa16
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#8 - String to Integer (atoi).cpp	
@@ -0,0 +1,62 @@
+class Solution {
+public:
+    int myAtoi(string str) {
+        
+        string to_conv;
+        for(int i=0; i<str.size() ; i++)
+        {
+            if(str[i]>='a'&&str[i]<='z')
+                break;
+            
+            to_conv.push_back(str[i]);
+        }
+        
+        if(to_conv.size()==0)
+            return 0;
+        
+        long x=0;
+        int sign = 1,i=0;
+        
+        while(to_conv[i]==' ')
+            i++;
+        
+        if(to_conv[i]=='-')
+        {
+            sign = -1;
+            i++;
+        }
+        else if(to_conv[i]=='+')
+        {
+            sign = 1;
+            i++;
+        }
+        
+        while(to_conv[i]=='0')
+            i++;
+        
+        while(str[i]!=' '&&to_conv[i]>='0'&&to_conv[i]<='9'&&i<to_conv.length()) 
+        {   
+            if(x<=INT_MAX&&x>=INT_MIN) 
+            {   
+			    x = x * 10 + to_conv[i] - '0';     
+		    }
+            
+            if(x>=INT_MAX)
+            {
+                
+                if(sign == -1)
+                {
+                    if(x*sign<=INT_MIN)
+                        return INT_MIN;
+                }
+                else
+                    return INT_MAX;
+            }
+            i++;   
+        }
+        
+        x*=sign;
+
+        return x;
+    }
+};

From e6f9cd642fbc7ae70317bae4510126799d7a78b5 Mon Sep 17 00:00:00 2001
From: Priyanshi Sharma <priyanshi417@gmail.com>
Date: Sun, 4 Oct 2020 03:42:46 +0530
Subject: [PATCH 040/203] Update pull_request_template.md

---
 .github/pull_request_template.md | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md
index e113e8d..201180a 100644
--- a/.github/pull_request_template.md
+++ b/.github/pull_request_template.md
@@ -1,10 +1,10 @@
-** Added the <Filename> Filename as**
+**Added the <Filename> Filename as**
 
 
-** Changes Proposed <Describe> in the PR Describe
+**Changes Proposed <Describe> in the PR. Describe**
 
 
-** I am assuring that the file is not redundant and making the Pull Request **
+**I am assuring that the file is not redundant and making the Pull Request**
 - [ ] Yes
  
  Read {% include Contributing.md %}

From da627341a5a3670bbd3e27a8dae1495d056d7186 Mon Sep 17 00:00:00 2001
From: Koulick Sadhu <ks2202@it.jgec.ac.in>
Date: Sun, 4 Oct 2020 03:51:58 +0530
Subject: [PATCH 041/203] Added Codechef Challenges

---
 .../CodeChef Challenges/CHFNSWAP_SEPT20B.cpp  | 54 +++++++++++++++++++
 1 file changed, 54 insertions(+)
 create mode 100644 ONLINE JUDGE/CodeChef Challenges/CHFNSWAP_SEPT20B.cpp

diff --git a/ONLINE JUDGE/CodeChef Challenges/CHFNSWAP_SEPT20B.cpp b/ONLINE JUDGE/CodeChef Challenges/CHFNSWAP_SEPT20B.cpp
new file mode 100644
index 0000000..c6b1793
--- /dev/null
+++ b/ONLINE JUDGE/CodeChef Challenges/CHFNSWAP_SEPT20B.cpp	
@@ -0,0 +1,54 @@
+#include<bits/stdc++.h>
+#define ll long long int
+#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
+#define MAX_LIMIT 10000000
+#define all(x) x.begin(),x.end()
+#define br break
+#define pb push_back
+using namespace std; 
+bool isPerfectSquare(long double x)
+{
+  long double sr = sqrt(x);
+  return ((sr - floor(sr)) == 0);
+}
+void solve(){
+ 	  //input
+ 	  ll n;
+ 	  cin>>n;
+ 	  ll sum=(n)*(n+1)/2;
+ 	  ll i;
+ 	  if(sum&1){
+		  cout<<0<<endl;
+		  return;
+	  }
+	  ll z=1+4*sum;
+	  ll ans=0;
+	  bool flag=0;
+	  if(isPerfectSquare(z)){
+		  ll x=sqrt(z);
+		  ans=(x-1)/2;
+		  flag=1;
+	  }
+	  ll ans1=0;
+	  if(flag){
+		    ans1+=(n-ans);
+		    ans1+=ans*(ans-1)/2;
+		    ll v=n-ans;
+		    ans1+=v*(v-1)/2;
+	  }
+	  else{
+		  ll g=sqrt(z);
+		  ans=(g-1)/2;
+		  ans1+=(n-ans);  
+	  }
+	  cout<<ans1<<endl;
+}     
+int32_t main()
+{	
+     fio;
+   ll t=1;
+   cin>>t;
+   while(t--){
+   	  solve();
+   }
+}

From 6d5b2e8a231631e8dc00c2ebda68d641aa2baffa Mon Sep 17 00:00:00 2001
From: kra-tosss <64043098+kra-tosss@users.noreply.github.com>
Date: Sun, 4 Oct 2020 11:40:47 +0530
Subject: [PATCH 042/203] added leetcode problems

---
 ONLINE JUDGE/LeetCode/#204-count-primes.cpp | 34 +++++++++++++++++++++
 1 file changed, 34 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#204-count-primes.cpp

diff --git a/ONLINE JUDGE/LeetCode/#204-count-primes.cpp b/ONLINE JUDGE/LeetCode/#204-count-primes.cpp
new file mode 100644
index 0000000..7cdde40
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#204-count-primes.cpp	
@@ -0,0 +1,34 @@
+class Solution {
+public:
+    bool is_prime(int n) {
+    // Assumes that n is a positive natural number
+    // We know 1 is not a prime number
+    if (n == 1) {
+        return false;
+    }
+
+    int i = 2;
+    // This will loop from 2 to int(sqrt(x))
+    while (i*i <= n) {
+        // Check if i divides x without leaving a remainder
+        if (n % i == 0) {
+            // This means that n has a factor in between 2 and sqrt(n)
+            // So it is not a prime number
+            return false;
+        }
+        i += 1;
+    }
+    // If we did not find any factor in the above loop,
+    // then n is a prime number
+    return true;
+}
+    int countPrimes(int n) {
+        if(n==1 ) return 0;
+        if(n==2 ) return 0;
+        int c=0;
+      for(int i=2 ; i<n; i++) {
+          if(is_prime(i)) c++;
+      }
+        return c;
+    }
+};

From 6874ea3981114401864e25ed33e8917a8a5b4d1d Mon Sep 17 00:00:00 2001
From: sharur7 <sharuraut7blog@gmail.com>
Date: Sun, 4 Oct 2020 14:03:06 +0530
Subject: [PATCH 043/203] Interpolation search added

---
 03-Arrays/MatrixRotation.cpp                  | 158 +++++++-------
 04-Sorting/InversionCount.cpp                 |  90 ++++----
 04-Sorting/countingsort.cpp                   |  56 ++---
 04-Sorting/dnfsorting.cpp                     |  64 +++---
 04-Sorting/mergeSort.cpp                      | 106 ++++-----
 04-Sorting/quickSort.cpp                      |  64 +++---
 04-Sorting/wavesort.cpp                       |  36 ++--
 05-Searching/Interpolation_Search.cpp         | 103 +++++++++
 05-Searching/LowerBound.cpp                   |  52 ++---
 05-Searching/UpperBound.cpp                   |  54 ++---
 09- Number Theory/BinaryExponentiation.cpp    |  76 +++----
 10- Recursion & Backtracking/sort_a_stack.cpp |  62 +++---
 18-Binary Tree/binary_to_DLL.cpp              |  84 ++++----
 C-plus-plus-Algorithms                        |   1 +
 .../01-Array/Sort Array of 0,1,2 .cpp         | 124 +++++------
 ONLINE JUDGE/LeetCode/#148-Sort_the_list.cpp  | 100 ++++-----
 .../LeetCode/#1550:Three-Consecutive-Odds.cpp |  33 ---
 ONLINE JUDGE/LeetCode/#2 Add-two-numbers.cpp  |  70 +++---
 ONLINE JUDGE/LeetCode/#328 Odd-Even-List.cpp  |  56 ++---
 ONLINE JUDGE/SPOJ/ACODE Alphacode.cpp         |  54 ++---
 ONLINE JUDGE/SPOJ/AGGRCOW Aggressive Cows.cpp | 110 +++++-----
 .../GSS1 Can you answer these queries I.cpp   | 182 ++++++++--------
 .../SPOJ/HORRIBLE Horrible Queries.cpp        | 202 +++++++++---------
 ONLINE JUDGE/SPOJ/INVCNT Inversion Count.cpp  | 130 +++++------
 ONLINE JUDGE/SPOJ/JULKA Julka.cpp             | 200 ++++++++---------
 .../SPOJ/PALIN The next Palindrome.cpp        | 154 ++++++-------
 ONLINE JUDGE/SPOJ/PRIME1 Prime Generator.cpp  |  56 ++---
 27 files changed, 1274 insertions(+), 1203 deletions(-)
 create mode 100644 05-Searching/Interpolation_Search.cpp
 mode change 100755 => 100644 09- Number Theory/BinaryExponentiation.cpp
 create mode 160000 C-plus-plus-Algorithms
 delete mode 100644 ONLINE JUDGE/LeetCode/#1550:Three-Consecutive-Odds.cpp

diff --git a/03-Arrays/MatrixRotation.cpp b/03-Arrays/MatrixRotation.cpp
index 6a92994..b48e65f 100644
--- a/03-Arrays/MatrixRotation.cpp
+++ b/03-Arrays/MatrixRotation.cpp
@@ -1,80 +1,80 @@
-#include<iostream>
-using namespace std;
-
-//Function to input the matrix from the user
-void inputMatrix(int matrix[][10], int row, int column)
-{
-   printf("\nEnter elements: \n");
-   for (int i = 0; i < row; ++i)
-      for (int j = 0; j < column; ++j)
-      {
-         printf("Enter a[%d][%d]: ", i + 1, j + 1);
-         cin>>matrix[i][j];
-      }
-}
-
-//Function to print a given matrix
-void printMatrix(int matrix[][10], int row, int column)
-{
-   for (int i = 0; i < row; ++i)
-        for (int j = 0; j < column; ++j)
-        {
-            printf("%d  ", matrix[i][j]);
-            if (j == column - 1)
-            printf("\n");
-        }
-}
-
-//Function to swap two integers
-void swap(int *a, int *b) 
-{ 
-    int t = *a; 
-    *a = *b; 
-    *b = t; 
-}
-
-//Function to find the transpose of a matrix
-void findTranspose(int matrix[][10], int transpose[][10],int row, int column)
-{
-    for(int i=0;i<row;i++)
-        for(int j=0;j<column;j++)
-            transpose[j][i] = matrix[i][j];
-}
-
-//Function to find the clockwise rotated matrix
-void findClockwiseMatrix(int matrix[][10], int clockwise[][10],int row, int column)
-{
-    findTranspose(matrix,clockwise,row,column);
-    for(int i=0;i<column;i++)
-        for(int j=0;j<row/2;j++)
-            swap(&clockwise[i][j], &clockwise[i][row-j-1]);            
-}
-
-//Function to find the antilcokwise rotated matrix
-void findAntiClockwiseMatrix(int matrix[][10], int aclockwise[][10],int row, int column)
-{
-    findTranspose(matrix,aclockwise,row,column);
-    for(int i=0;i<column/2;i++)
-        for(int j=0;j<row;j++)
-            swap(&aclockwise[i][j], &aclockwise[column-i-1][j]);              
-}
-
-int main()
-{
-    int matrix[10][10],clockwise[10][10],aclockwise[10][10],row,column;
-
-    printf("\nEnter the row and column values: ");
-    cin>>row>>column;
-
-    inputMatrix(matrix,row,column); 
-    //Function to find out the clockwise rotated matrix
-    findClockwiseMatrix(matrix,clockwise,row,column); 
-    //Function to find out the anticlockwise rotated matrix
-    findAntiClockwiseMatrix(matrix,aclockwise,row,column);  
-
-    printf("\nMatrix rotated by 90 degree clockwise: \n");
-    printMatrix(clockwise,column,row);
-
-    printf("\nMatrix rotated by 90 degree anticlockwise: \n");
-    printMatrix(aclockwise,column,row);
+#include<iostream>
+using namespace std;
+
+//Function to input the matrix from the user
+void inputMatrix(int matrix[][10], int row, int column)
+{
+   printf("\nEnter elements: \n");
+   for (int i = 0; i < row; ++i)
+      for (int j = 0; j < column; ++j)
+      {
+         printf("Enter a[%d][%d]: ", i + 1, j + 1);
+         cin>>matrix[i][j];
+      }
+}
+
+//Function to print a given matrix
+void printMatrix(int matrix[][10], int row, int column)
+{
+   for (int i = 0; i < row; ++i)
+        for (int j = 0; j < column; ++j)
+        {
+            printf("%d  ", matrix[i][j]);
+            if (j == column - 1)
+            printf("\n");
+        }
+}
+
+//Function to swap two integers
+void swap(int *a, int *b) 
+{ 
+    int t = *a; 
+    *a = *b; 
+    *b = t; 
+}
+
+//Function to find the transpose of a matrix
+void findTranspose(int matrix[][10], int transpose[][10],int row, int column)
+{
+    for(int i=0;i<row;i++)
+        for(int j=0;j<column;j++)
+            transpose[j][i] = matrix[i][j];
+}
+
+//Function to find the clockwise rotated matrix
+void findClockwiseMatrix(int matrix[][10], int clockwise[][10],int row, int column)
+{
+    findTranspose(matrix,clockwise,row,column);
+    for(int i=0;i<column;i++)
+        for(int j=0;j<row/2;j++)
+            swap(&clockwise[i][j], &clockwise[i][row-j-1]);            
+}
+
+//Function to find the antilcokwise rotated matrix
+void findAntiClockwiseMatrix(int matrix[][10], int aclockwise[][10],int row, int column)
+{
+    findTranspose(matrix,aclockwise,row,column);
+    for(int i=0;i<column/2;i++)
+        for(int j=0;j<row;j++)
+            swap(&aclockwise[i][j], &aclockwise[column-i-1][j]);              
+}
+
+int main()
+{
+    int matrix[10][10],clockwise[10][10],aclockwise[10][10],row,column;
+
+    printf("\nEnter the row and column values: ");
+    cin>>row>>column;
+
+    inputMatrix(matrix,row,column); 
+    //Function to find out the clockwise rotated matrix
+    findClockwiseMatrix(matrix,clockwise,row,column); 
+    //Function to find out the anticlockwise rotated matrix
+    findAntiClockwiseMatrix(matrix,aclockwise,row,column);  
+
+    printf("\nMatrix rotated by 90 degree clockwise: \n");
+    printMatrix(clockwise,column,row);
+
+    printf("\nMatrix rotated by 90 degree anticlockwise: \n");
+    printMatrix(aclockwise,column,row);
 }
\ No newline at end of file
diff --git a/04-Sorting/InversionCount.cpp b/04-Sorting/InversionCount.cpp
index 1385505..0c37ca0 100644
--- a/04-Sorting/InversionCount.cpp
+++ b/04-Sorting/InversionCount.cpp
@@ -1,46 +1,46 @@
-#include<iostream>
-using namespace std;
-int merge(int *a, int s, int e){
-	int mid= (s+e)/2;
-	int i=s;
-	int j=mid+1;
-	int k=s;
-	int temp[1000];
-	int cnt=0;
-
-	while(i<=mid and j<=e){
-		if(a[i]<=a[j]){
-			temp[k++]=a[i++];
-		}
-		else{
-			temp[k++]=a[i++];
-			cnt+= mid-i+1;
-		}
-	}
-	while(i<=mid){
-		temp[k++]= a[i++];
-	}
-	while(j<=e){
-		temp[k++]=a[i++];
-	}
-	for(int i=s;i<=e;i++){
-		a[i]=temp[i];
-}
-	return cnt;
-}
-int inversion_count(int *a, int s, int e){
-	if(s>=e){
-		return 0;
-	}
-	int mid= (s+e)/2;
-	int x= inversion_count(a,s,mid);
-	int y= inversion_count(a,mid+1,e);
-	int z= merge(a,s,e);
-	return x+y+z;
-}
-int main()
-{
-	int a[]= {1,3,4,6,8,0};
-	int n= sizeof(a)/sizeof(int);
-	cout<<inversion_count(a,0,n-1)<<endl;
+#include<iostream>
+using namespace std;
+int merge(int *a, int s, int e){
+	int mid= (s+e)/2;
+	int i=s;
+	int j=mid+1;
+	int k=s;
+	int temp[1000];
+	int cnt=0;
+
+	while(i<=mid and j<=e){
+		if(a[i]<=a[j]){
+			temp[k++]=a[i++];
+		}
+		else{
+			temp[k++]=a[i++];
+			cnt+= mid-i+1;
+		}
+	}
+	while(i<=mid){
+		temp[k++]= a[i++];
+	}
+	while(j<=e){
+		temp[k++]=a[i++];
+	}
+	for(int i=s;i<=e;i++){
+		a[i]=temp[i];
+}
+	return cnt;
+}
+int inversion_count(int *a, int s, int e){
+	if(s>=e){
+		return 0;
+	}
+	int mid= (s+e)/2;
+	int x= inversion_count(a,s,mid);
+	int y= inversion_count(a,mid+1,e);
+	int z= merge(a,s,e);
+	return x+y+z;
+}
+int main()
+{
+	int a[]= {1,3,4,6,8,0};
+	int n= sizeof(a)/sizeof(int);
+	cout<<inversion_count(a,0,n-1)<<endl;
 }
\ No newline at end of file
diff --git a/04-Sorting/countingsort.cpp b/04-Sorting/countingsort.cpp
index 5a79252..3194eec 100644
--- a/04-Sorting/countingsort.cpp
+++ b/04-Sorting/countingsort.cpp
@@ -1,28 +1,28 @@
-#include<iostream>
-using namespace std;
-void countingsort(int *a, int n){
-	int largest= -1;
-	for(int i=0;i<n;i++){
-		largest= max(largest,a[i]);
-	}
-	int *freq= new int[largest]{0};
-	for(int i=0;i<n;i++){
-		freq[a[i]]++;
-	}
-	int j=0;
-	for(int i=0;i<n;i++){
-		a[j]=i;
-		freq[i]--;
-		j++;
-	}
-}	
-
-int  main()
-{
-	int a[]= {2,3,5,12,19,6,8};
-	int n= sizeof(a)/sizeof(int);
-	countingsort(a,n);
-	for(int i=0;i<n;i++){
-		cout<<a[i]<<" ";
-	}
-}
+#include<iostream>
+using namespace std;
+void countingsort(int *a, int n){
+	int largest= -1;
+	for(int i=0;i<n;i++){
+		largest= max(largest,a[i]);
+	}
+	int *freq= new int[largest]{0};
+	for(int i=0;i<n;i++){
+		freq[a[i]]++;
+	}
+	int j=0;
+	for(int i=0;i<n;i++){
+		a[j]=i;
+		freq[i]--;
+		j++;
+	}
+}	
+
+int  main()
+{
+	int a[]= {2,3,5,12,19,6,8};
+	int n= sizeof(a)/sizeof(int);
+	countingsort(a,n);
+	for(int i=0;i<n;i++){
+		cout<<a[i]<<" ";
+	}
+}
diff --git a/04-Sorting/dnfsorting.cpp b/04-Sorting/dnfsorting.cpp
index ec8ddfe..a0ad30c 100644
--- a/04-Sorting/dnfsorting.cpp
+++ b/04-Sorting/dnfsorting.cpp
@@ -1,32 +1,32 @@
-#include<iostream>
-using namespace std;
-int dnfsort(int a[], int n){
-	int low= 0;
-	int high= n-1;
-	int mid=0;
-	while(mid<=high){
-		if(a[mid]==0){
-			swap(a[mid],a[low]);
-			mid++;
-			low++;
-		}
-		if(a[mid]==1){
-			mid++;
-		}
-		if(a[mid]==2){
-			swap(a[mid],a[high]);
-			high--;
-		}
-	}
-	return 0;
-}
-
-int main()
-{
-	int a[]= {1,0,0,2,1,1,0,0,1};
-	int n= sizeof(a)/sizeof(int);
-	dnfsort(a,n);
-    for(int i=0;i<n;i++){
-    	cout<<a[i]<<" ";
-    }
-}
+#include<iostream>
+using namespace std;
+int dnfsort(int a[], int n){
+	int low= 0;
+	int high= n-1;
+	int mid=0;
+	while(mid<=high){
+		if(a[mid]==0){
+			swap(a[mid],a[low]);
+			mid++;
+			low++;
+		}
+		if(a[mid]==1){
+			mid++;
+		}
+		if(a[mid]==2){
+			swap(a[mid],a[high]);
+			high--;
+		}
+	}
+	return 0;
+}
+
+int main()
+{
+	int a[]= {1,0,0,2,1,1,0,0,1};
+	int n= sizeof(a)/sizeof(int);
+	dnfsort(a,n);
+    for(int i=0;i<n;i++){
+    	cout<<a[i]<<" ";
+    }
+}
diff --git a/04-Sorting/mergeSort.cpp b/04-Sorting/mergeSort.cpp
index 9c29285..c8902ee 100644
--- a/04-Sorting/mergeSort.cpp
+++ b/04-Sorting/mergeSort.cpp
@@ -1,54 +1,54 @@
-#include<iostream>
-using namespace std;
-void merge(int *a, int s, int e){
-	int temp[100];
-	int mid=(s+e)/2;
-	int i=s;
-	int j=mid;
-	int k= s;
-	
-	while(i<=mid && j<=e){
-		if(a[i]<a[j]){
-			temp[k++]=a[i++];
-		}
-		else {
-			temp[k++]=a[j++];		}
-		}
-		while(i<=mid){
-			temp[k++]=a[i++];
-		}
-		while(j<=e){
-			temp[k++]=a[j++];
-		}
-		for(int i=s;i<=e;i++){
-			a[i]=temp[i];
-		}
-		}
-
-
-void mergeSort(int a[], int s, int e){
-	//Base Case
-	if(s>=e){
-		return;
-	}
-	//Rec Case
-	//1. Devide 
-    int mid= (s+e)/2;
-    mergeSort(a,s,mid);
-    mergeSort(a,mid+1,e);
-    merge(a,s,e);
-
-}
-
-int main()
-{
-	int n;cin>>n;
-	int a[1000];
-	for(int i=0;i<n;i++){
-		cin>>a[i];
-	}
-	mergeSort(a,0,n-1);
-	for(int i=0;i<n;i++){
-		cout<<a[i]<<" ";
-	}
+#include<iostream>
+using namespace std;
+void merge(int *a, int s, int e){
+	int temp[100];
+	int mid=(s+e)/2;
+	int i=s;
+	int j=mid;
+	int k= s;
+	
+	while(i<=mid && j<=e){
+		if(a[i]<a[j]){
+			temp[k++]=a[i++];
+		}
+		else {
+			temp[k++]=a[j++];		}
+		}
+		while(i<=mid){
+			temp[k++]=a[i++];
+		}
+		while(j<=e){
+			temp[k++]=a[j++];
+		}
+		for(int i=s;i<=e;i++){
+			a[i]=temp[i];
+		}
+		}
+
+
+void mergeSort(int a[], int s, int e){
+	//Base Case
+	if(s>=e){
+		return;
+	}
+	//Rec Case
+	//1. Devide 
+    int mid= (s+e)/2;
+    mergeSort(a,s,mid);
+    mergeSort(a,mid+1,e);
+    merge(a,s,e);
+
+}
+
+int main()
+{
+	int n;cin>>n;
+	int a[1000];
+	for(int i=0;i<n;i++){
+		cin>>a[i];
+	}
+	mergeSort(a,0,n-1);
+	for(int i=0;i<n;i++){
+		cout<<a[i]<<" ";
+	}
 }
\ No newline at end of file
diff --git a/04-Sorting/quickSort.cpp b/04-Sorting/quickSort.cpp
index 674092e..4e1cb7b 100644
--- a/04-Sorting/quickSort.cpp
+++ b/04-Sorting/quickSort.cpp
@@ -1,33 +1,33 @@
-#include<iostream>
-using namespace std;
-void partition(int *a, int s, int e){
-  int i=s-1;
-  int j=s;
-  int pivot= a[e];
-  for(;j<e-1){
-  	if(a[j]<=pivot){
-  		i=i+1;
-     swap(a[i],a[j]);
-  	}
-  	j=j+1;
-  }
-  swap(a[i+1],a[e]);
-  return i+1;
-  }
-void quickSort(int *a, int s, int e){
-	if(s<=e){
-		return;
-	}
-	int p= partition(a,s,e);
-	quickSort(a,s,p-1);
-	quickSort(a,p+1,e);
-};
-int main()
-{
-	int a[]= {2,3,4,5,7,1,0};
-	int n= sizeof(a)/sizeof(int);
-	quickSort(a,0,n-1);
-	for(int i=0;i<n;i++){
-		cout<<a[i]<<" ";
-	}
+#include<iostream>
+using namespace std;
+void partition(int *a, int s, int e){
+  int i=s-1;
+  int j=s;
+  int pivot= a[e];
+  for(;j<e-1){
+  	if(a[j]<=pivot){
+  		i=i+1;
+     swap(a[i],a[j]);
+  	}
+  	j=j+1;
+  }
+  swap(a[i+1],a[e]);
+  return i+1;
+  }
+void quickSort(int *a, int s, int e){
+	if(s<=e){
+		return;
+	}
+	int p= partition(a,s,e);
+	quickSort(a,s,p-1);
+	quickSort(a,p+1,e);
+};
+int main()
+{
+	int a[]= {2,3,4,5,7,1,0};
+	int n= sizeof(a)/sizeof(int);
+	quickSort(a,0,n-1);
+	for(int i=0;i<n;i++){
+		cout<<a[i]<<" ";
+	}
 }
\ No newline at end of file
diff --git a/04-Sorting/wavesort.cpp b/04-Sorting/wavesort.cpp
index 7c0e4ed..dcf2e36 100644
--- a/04-Sorting/wavesort.cpp
+++ b/04-Sorting/wavesort.cpp
@@ -1,19 +1,19 @@
-#include<iostream>
-using namespace std;
-int main()
-{
-	int a[]= {1,2,6,3,8,5,9};
-	int n= sizeof(a)/sizeof(int);
-	for(int i=0;i<n;i+=2){
-        
-		if(i!=0 and a[i]<a[i-1]){
-			swap(a[i],a[i-1]);
-		}
-		if(i!=(n-1) and a[i]<a[i+1]){
-			swap(a[i],a[i+1]);
-		}
-	}
-	for(int i=0;i<n;i++){
-		cout<<a[i]<<" ";
-	}
+#include<iostream>
+using namespace std;
+int main()
+{
+	int a[]= {1,2,6,3,8,5,9};
+	int n= sizeof(a)/sizeof(int);
+	for(int i=0;i<n;i+=2){
+        
+		if(i!=0 and a[i]<a[i-1]){
+			swap(a[i],a[i-1]);
+		}
+		if(i!=(n-1) and a[i]<a[i+1]){
+			swap(a[i],a[i+1]);
+		}
+	}
+	for(int i=0;i<n;i++){
+		cout<<a[i]<<" ";
+	}
 }
\ No newline at end of file
diff --git a/05-Searching/Interpolation_Search.cpp b/05-Searching/Interpolation_Search.cpp
new file mode 100644
index 0000000..34329b5
--- /dev/null
+++ b/05-Searching/Interpolation_Search.cpp
@@ -0,0 +1,103 @@
+//INTERPOLATION SEARCH
+#include<bits/stdc++.h> //Importing library (This is the special type of library which will include all basic libraries)
+
+using namespace std;
+
+// If the searching element is present it will return its index, else it will return -1. 
+
+int interpolationSearch(int arr[], int n, int x) {
+  int low = 0, high = (n - 1); //Assigning lower index as 0 and higher index as n-1
+
+  while (low <= high && x >= arr[low] && x <= arr[high]) {
+    if (low == high) {
+      if (arr[low] == x) return low;
+      return -1;
+    }
+    // Probing the position with keeping uniform distribution in mind. 
+    int pos = low + (((double)(high - low) /
+      (arr[high] - arr[low])) * (x - arr[low]));
+
+    // Condition of element to be found 
+    if (arr[pos] == x)
+      return pos;
+
+    // If x is larger, x is in upper part 
+    if (arr[pos] < x)
+      low = pos + 1;
+
+    // If x is smaller, x is in the lower part 
+    else
+      high = pos - 1;
+  }
+  return -1;
+}
+
+int main() //Starting our main function 
+{
+
+  int num, x, loc;
+  std::cout << "Enter size of an array: ";
+  std::cin >> num;
+  int arr[num]; //Creating array of the size num
+  std::cout << "Enter elements: " << std::endl;
+
+  for (int i = 0; i < num; i++) //Enter the elements in the array
+  {
+    std::cin >> arr[i];
+  }
+
+  //Sorting our array
+
+  int n = sizeof(arr) / sizeof(arr[0]);
+  sort(arr, arr + n);
+
+  cout << "\nArray after sorting using "
+  "default sort is : \n" << std::endl;
+  for (int i = 0; i < n; ++i) {
+    cout << arr[i] << " ";
+
+  }
+  cout << std::endl;
+
+  //Entering the searching element
+  std::cout << "Enter element to be searched: " << std::endl;
+  cin >> x; //Element to be searched 
+  int index = interpolationSearch(arr, n, x);
+  //If element was found 
+  if (index != -1)
+    cout << "Element found at index " << index; //Returning the index pf the element
+  else
+    cout << "Element not found."; //Returning -1 as element has not found 
+
+  return 0;
+}
+
+/*
+SAMPLE INPUT:
+
+5 
+1
+7
+4
+9
+2 
+4
+
+SAMPLE OUTPUT:
+Enter size of an array: Enter elements: 
+
+Array after sorting using default sort is : 
+
+1 2 4 7 9 
+Enter element to be searched: 
+4
+Element found at index 2
+
+Time Complexity of Interpolation Search Algorithm
+Average Case: O (log log n) 
+Worst Case: O(N)
+
+Space Complexity of Interpolation Search Algorithm is O(1)
+*/
+
+
diff --git a/05-Searching/LowerBound.cpp b/05-Searching/LowerBound.cpp
index 8c5c73f..df49155 100644
--- a/05-Searching/LowerBound.cpp
+++ b/05-Searching/LowerBound.cpp
@@ -1,27 +1,27 @@
-/*
-Lower Bound
-
-*/
-#include<bits/stdc++.h>
-using namespace std;
-
-int main()
-{
-    int arr[]={2,6,8,12,15,29,35,51,51,167,232,303,489,500};
-    int target=51;
-
-    int l=0,r=14;
-    while(l<r)
-    {
-        int mid=l+(r-l)/2;
-        if(target<=arr[mid])
-        {
-           r=mid;
-        }
-        else{
-            l=mid+1;
-        }
-    }
-    cout<<l;
-
+/*
+Lower Bound
+
+*/
+#include<bits/stdc++.h>
+using namespace std;
+
+int main()
+{
+    int arr[]={2,6,8,12,15,29,35,51,51,167,232,303,489,500};
+    int target=51;
+
+    int l=0,r=14;
+    while(l<r)
+    {
+        int mid=l+(r-l)/2;
+        if(target<=arr[mid])
+        {
+           r=mid;
+        }
+        else{
+            l=mid+1;
+        }
+    }
+    cout<<l;
+
 }
\ No newline at end of file
diff --git a/05-Searching/UpperBound.cpp b/05-Searching/UpperBound.cpp
index 54d5ba9..93e0317 100644
--- a/05-Searching/UpperBound.cpp
+++ b/05-Searching/UpperBound.cpp
@@ -1,28 +1,28 @@
-/*
-Upper Bound
-
-*/
-#include<bits/stdc++.h>
-using namespace std;
-
-int main()
-{
-    int arr[]={2,6,8,12,15,29,35,51,51,167,232,303,489,500};
-    int target=51;
-
-    int l=0,r=14;
-    while(l<r)
-    {
-        int mid=l+(r-l)/2;
-        if(target>=arr[mid])
-        {
-          
-           l=mid+1;
-        }
-        else{
-             r=mid;
-        }
-    }
-    cout<<l;
-
+/*
+Upper Bound
+
+*/
+#include<bits/stdc++.h>
+using namespace std;
+
+int main()
+{
+    int arr[]={2,6,8,12,15,29,35,51,51,167,232,303,489,500};
+    int target=51;
+
+    int l=0,r=14;
+    while(l<r)
+    {
+        int mid=l+(r-l)/2;
+        if(target>=arr[mid])
+        {
+          
+           l=mid+1;
+        }
+        else{
+             r=mid;
+        }
+    }
+    cout<<l;
+
 }
\ No newline at end of file
diff --git a/09- Number Theory/BinaryExponentiation.cpp b/09- Number Theory/BinaryExponentiation.cpp
old mode 100755
new mode 100644
index 12f2c33..5856570
--- a/09- Number Theory/BinaryExponentiation.cpp	
+++ b/09- Number Theory/BinaryExponentiation.cpp	
@@ -1,38 +1,38 @@
-// Binary Exponentiation algorithm
-// Iterative solution
-
-#include <iostream>
-#include <cmath>
-
-using namespace std;
-
-int64_t binaryExponentiation(int64_t a, int64_t n){
-    // Initializing result with 1
-    int64_t res = 1;
-    
-    // Looping to calculate result
-    while(n > 0){
-        // Checking if bit is high or not
-        if(n & 1){
-            // Updating res only when bit is high
-            res = res * a;
-        }
-
-        // Updating a
-        a = a * a;
-        // Right shift 
-        n = n >> 1;
-    }
-    return res;
-}
- 
-int main(){
-    int64_t a, n;
-    cout << endl << "Enter a & n : ";
-    cin >> a >> n;
-
-    int64_t res = binaryExponentiation(a, n);
-    cout << endl << "Result : " << res;
-
-    return 0;
-}
+// Binary Exponentiation algorithm
+// Iterative solution
+
+#include <iostream>
+#include <cmath>
+
+using namespace std;
+
+int64_t binaryExponentiation(int64_t a, int64_t n){
+    // Initializing result with 1
+    int64_t res = 1;
+    
+    // Looping to calculate result
+    while(n > 0){
+        // Checking if bit is high or not
+        if(n & 1){
+            // Updating res only when bit is high
+            res = res * a;
+        }
+
+        // Updating a
+        a = a * a;
+        // Right shift 
+        n = n >> 1;
+    }
+    return res;
+}
+ 
+int main(){
+    int64_t a, n;
+    cout << endl << "Enter a & n : ";
+    cin >> a >> n;
+
+    int64_t res = binaryExponentiation(a, n);
+    cout << endl << "Result : " << res;
+
+    return 0;
+}
diff --git a/10- Recursion & Backtracking/sort_a_stack.cpp b/10- Recursion & Backtracking/sort_a_stack.cpp
index f4dc000..7ff74df 100644
--- a/10- Recursion & Backtracking/sort_a_stack.cpp	
+++ b/10- Recursion & Backtracking/sort_a_stack.cpp	
@@ -1,32 +1,32 @@
-/*The structure of the class is
-class SortedStack{
-public:
-	stack<int> s;
-	void sort();
-};
-*/
-
-/* The below method sorts the stack s 
-you are required to complete the below method */
-void sortinsert(stack<int>& s,int temp)
-{
-    if(s.empty() || temp>s.top())
-    {
-        s.push(temp);
-        return;
-    }
-    int x=s.top();
-    s.pop();
-    sortinsert(s,temp);
-    s.push(x);
-}
-void SortedStack :: sort()
-{
-   if(!s.empty())
-   {
-       int temp=s.top();
-       s.pop();
-       sort();
-       sortinsert(s,temp);
-   }
+/*The structure of the class is
+class SortedStack{
+public:
+	stack<int> s;
+	void sort();
+};
+*/
+
+/* The below method sorts the stack s 
+you are required to complete the below method */
+void sortinsert(stack<int>& s,int temp)
+{
+    if(s.empty() || temp>s.top())
+    {
+        s.push(temp);
+        return;
+    }
+    int x=s.top();
+    s.pop();
+    sortinsert(s,temp);
+    s.push(x);
+}
+void SortedStack :: sort()
+{
+   if(!s.empty())
+   {
+       int temp=s.top();
+       s.pop();
+       sort();
+       sortinsert(s,temp);
+   }
 }
\ No newline at end of file
diff --git a/18-Binary Tree/binary_to_DLL.cpp b/18-Binary Tree/binary_to_DLL.cpp
index 429f6f0..e630d5e 100644
--- a/18-Binary Tree/binary_to_DLL.cpp	
+++ b/18-Binary Tree/binary_to_DLL.cpp	
@@ -1,42 +1,42 @@
-
-// } Driver Code Ends
-
-
-/* Structure for tree and linked list
-
-struct Node
-{
-    int data;
-    struct Node* left;
-    struct Node* right;
-    
-    Node(int x){
-        data = x;
-        left = right = NULL;
-    }
-};
- */
-
-// This function should convert a given Binary tree to Doubly
-// Linked List
-
-void bToDLL(Node *root, Node **head)
-{
-    if(root==NULL)
-        return;
-    static Node* prev=NULL;
-    bToDLL(root->left,head);
-    if(*head==NULL)
-    {
-        prev=NULL;
-        *head=root;
-    }
-    else
-    {
-        root->left=prev;
-        prev->right=root;
-    }
-    prev=root;
-    bToDLL(root->right,head);
-}
-
+
+// } Driver Code Ends
+
+
+/* Structure for tree and linked list
+
+struct Node
+{
+    int data;
+    struct Node* left;
+    struct Node* right;
+    
+    Node(int x){
+        data = x;
+        left = right = NULL;
+    }
+};
+ */
+
+// This function should convert a given Binary tree to Doubly
+// Linked List
+
+void bToDLL(Node *root, Node **head)
+{
+    if(root==NULL)
+        return;
+    static Node* prev=NULL;
+    bToDLL(root->left,head);
+    if(*head==NULL)
+    {
+        prev=NULL;
+        *head=root;
+    }
+    else
+    {
+        root->left=prev;
+        prev->right=root;
+    }
+    prev=root;
+    bToDLL(root->right,head);
+}
+
diff --git a/C-plus-plus-Algorithms b/C-plus-plus-Algorithms
new file mode 160000
index 0000000..018d92c
--- /dev/null
+++ b/C-plus-plus-Algorithms
@@ -0,0 +1 @@
+Subproject commit 018d92c54b9f386292f5b1bd3c940d4ccb72d427
diff --git a/Interview Problems/01-Array/Sort Array of 0,1,2 .cpp b/Interview Problems/01-Array/Sort Array of 0,1,2 .cpp
index e562d30..1203710 100644
--- a/Interview Problems/01-Array/Sort Array of 0,1,2 .cpp	
+++ b/Interview Problems/01-Array/Sort Array of 0,1,2 .cpp	
@@ -1,62 +1,62 @@
-// C++ program to sort an array 
-// with 0, 1 and 2 in a single pass 
-#include <bits/stdc++.h> 
-using namespace std; 
-
-// Function to sort the input array, 
-// the array is assumed 
-// to have values in {0, 1, 2} 
-void sort012(int a[], int arr_size) 
-{ 
-	int lo = 0; 
-	int hi = arr_size - 1; 
-	int mid = 0; 
-
-	// Iterate till all the elements 
-	// are sorted 
-	while (mid <= hi) { 
-		switch (a[mid]) { 
-
-		// If the element is 0 
-		case 0: 
-			swap(a[lo++], a[mid++]); 
-			break; 
-
-		// If the element is 1 . 
-		case 1: 
-			mid++; 
-			break; 
-
-		// If the element is 2 
-		case 2: 
-			swap(a[mid], a[hi--]); 
-			break; 
-		} 
-	} 
-} 
-
-// Function to print array arr[] 
-void printArray(int arr[], int arr_size) 
-{ 
-	// Iterate and print every element 
-	for (int i = 0; i < arr_size; i++) 
-		cout << arr[i] << " "; 
-} 
-
-// Driver Code 
-int main() 
-{ 
-	int arr[] = { 0, 1, 1, 0, 1, 2, 1, 2, 0, 0, 0, 1 }; 
-	int n = sizeof(arr) / sizeof(arr[0]); 
-
-	sort012(arr, n); 
-
-	cout << "array after segregation "; 
-
-	printArray(arr, n); 
-
-	return 0; 
-} 
-
-// This code is contributed by Shivi_Aggarwal 
-
+// C++ program to sort an array 
+// with 0, 1 and 2 in a single pass 
+#include <bits/stdc++.h> 
+using namespace std; 
+
+// Function to sort the input array, 
+// the array is assumed 
+// to have values in {0, 1, 2} 
+void sort012(int a[], int arr_size) 
+{ 
+	int lo = 0; 
+	int hi = arr_size - 1; 
+	int mid = 0; 
+
+	// Iterate till all the elements 
+	// are sorted 
+	while (mid <= hi) { 
+		switch (a[mid]) { 
+
+		// If the element is 0 
+		case 0: 
+			swap(a[lo++], a[mid++]); 
+			break; 
+
+		// If the element is 1 . 
+		case 1: 
+			mid++; 
+			break; 
+
+		// If the element is 2 
+		case 2: 
+			swap(a[mid], a[hi--]); 
+			break; 
+		} 
+	} 
+} 
+
+// Function to print array arr[] 
+void printArray(int arr[], int arr_size) 
+{ 
+	// Iterate and print every element 
+	for (int i = 0; i < arr_size; i++) 
+		cout << arr[i] << " "; 
+} 
+
+// Driver Code 
+int main() 
+{ 
+	int arr[] = { 0, 1, 1, 0, 1, 2, 1, 2, 0, 0, 0, 1 }; 
+	int n = sizeof(arr) / sizeof(arr[0]); 
+
+	sort012(arr, n); 
+
+	cout << "array after segregation "; 
+
+	printArray(arr, n); 
+
+	return 0; 
+} 
+
+// This code is contributed by Shivi_Aggarwal 
+
diff --git a/ONLINE JUDGE/LeetCode/#148-Sort_the_list.cpp b/ONLINE JUDGE/LeetCode/#148-Sort_the_list.cpp
index 5f0f2b5..a7c5b18 100644
--- a/ONLINE JUDGE/LeetCode/#148-Sort_the_list.cpp	
+++ b/ONLINE JUDGE/LeetCode/#148-Sort_the_list.cpp	
@@ -1,51 +1,51 @@
-/**
- * Definition for singly-linked list.
- * struct ListNode {
- *     int val;
- *     ListNode *next;
- *     ListNode() : val(0), next(nullptr) {}
- *     ListNode(int x) : val(x), next(nullptr) {}
- *     ListNode(int x, ListNode *next) : val(x), next(next) {}
- * };
- */
-class Solution {
-public:
-    ListNode* sortList(ListNode* head) {
-        if(head==NULL or head->next==NULL){
-            return head;
-        }
-        ListNode*slow=head;
-        ListNode*fast= head->next;
-        while(fast!=NULL and fast->next!=NULL){
-            slow= slow->next;
-            fast= fast->next->next;
-        }
-        ListNode*mid= slow->next;
-        slow->next= NULL;
-        ListNode*left= sortList(head);
-        ListNode*right= sortList(mid);
-        return mergeSortListNode(left,right);
-    }
-    ListNode*mergeSortListNode(ListNode*l1, ListNode*l2){
-        ListNode dummy(0);
-        ListNode*curr= &dummy;
-        while(l1!=NULL and l2!=NULL){
-            if(l1->val<l2->val){
-                curr->next= l1;
-                l1=l1->next;
-            }
-            else{
-                curr->next=l2;
-                l2= l2->next;
-            }
-            curr= curr->next;
-        }
-        if(l1!=NULL){
-            curr->next= l1;
-        }
-        else{
-            curr->next= l2;
-        }
-        return dummy.next;
-    }
+/**
+ * Definition for singly-linked list.
+ * struct ListNode {
+ *     int val;
+ *     ListNode *next;
+ *     ListNode() : val(0), next(nullptr) {}
+ *     ListNode(int x) : val(x), next(nullptr) {}
+ *     ListNode(int x, ListNode *next) : val(x), next(next) {}
+ * };
+ */
+class Solution {
+public:
+    ListNode* sortList(ListNode* head) {
+        if(head==NULL or head->next==NULL){
+            return head;
+        }
+        ListNode*slow=head;
+        ListNode*fast= head->next;
+        while(fast!=NULL and fast->next!=NULL){
+            slow= slow->next;
+            fast= fast->next->next;
+        }
+        ListNode*mid= slow->next;
+        slow->next= NULL;
+        ListNode*left= sortList(head);
+        ListNode*right= sortList(mid);
+        return mergeSortListNode(left,right);
+    }
+    ListNode*mergeSortListNode(ListNode*l1, ListNode*l2){
+        ListNode dummy(0);
+        ListNode*curr= &dummy;
+        while(l1!=NULL and l2!=NULL){
+            if(l1->val<l2->val){
+                curr->next= l1;
+                l1=l1->next;
+            }
+            else{
+                curr->next=l2;
+                l2= l2->next;
+            }
+            curr= curr->next;
+        }
+        if(l1!=NULL){
+            curr->next= l1;
+        }
+        else{
+            curr->next= l2;
+        }
+        return dummy.next;
+    }
 };
\ No newline at end of file
diff --git a/ONLINE JUDGE/LeetCode/#1550:Three-Consecutive-Odds.cpp b/ONLINE JUDGE/LeetCode/#1550:Three-Consecutive-Odds.cpp
deleted file mode 100644
index afc4f96..0000000
--- a/ONLINE JUDGE/LeetCode/#1550:Three-Consecutive-Odds.cpp	
+++ /dev/null
@@ -1,33 +0,0 @@
-#include<bits/stdc++.h>
-#include<string.h>
-#define ll long long int
-#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
-#define pb push_back
-#define endl "\n"
-using namespace std;
-bool threeConsecutiveOdds(vector<int>& arr) {
-        bool flag=false;
-        for(int i=1;i<arr.size()-1;i++){
-            if(arr[i]&1 and arr[i-1]&1 and arr[i+1]&1){
-                flag=true;
-                break;
-            }
-        }
-        return flag;
-}
-void solve(){
-    //input
-    int n;
-    cin>>n;
-    vector<int>arr(n);
-    for(int i=0;i<n;i++){
-		cin>>arr[i];
-    }
-    cout<<threeConsecutiveOdds(arr);
-}
-int main()
-{
-    fio;
-    solve();
-}
- 
diff --git a/ONLINE JUDGE/LeetCode/#2 Add-two-numbers.cpp b/ONLINE JUDGE/LeetCode/#2 Add-two-numbers.cpp
index 4f2a6f1..a015ed7 100644
--- a/ONLINE JUDGE/LeetCode/#2 Add-two-numbers.cpp	
+++ b/ONLINE JUDGE/LeetCode/#2 Add-two-numbers.cpp	
@@ -1,36 +1,36 @@
-/**
- * Definition for singly-linked list.
- * struct ListNode {
- *     int val;
- *     ListNode *next;
- *     ListNode() : val(0), next(nullptr) {}
- *     ListNode(int x) : val(x), next(nullptr) {}
- *     ListNode(int x, ListNode *next) : val(x), next(next) {}
- * };
- */
-class Solution {
-public:
-    ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) {
-        ListNode*temp= new ListNode(-1);
-        ListNode*curr= temp;
-        int carry=0;
-        while(l1 or l2){
-            int n1= l1?l1->val:0;
-            int n2= l2?l2->val:0;
-            int sum= n1+n2+ carry;
-            carry= sum/10;
-            curr->next= new ListNode(sum%10);
-            curr= curr->next;
-            if(l1){
-                l1= l1->next;
-            }
-            if(l2){
-                l2= l2->next;
-            }
-            if(carry){
-                curr->next= new ListNode(carry);
-            }
-        }
-        return temp->next;
-    }
+/**
+ * Definition for singly-linked list.
+ * struct ListNode {
+ *     int val;
+ *     ListNode *next;
+ *     ListNode() : val(0), next(nullptr) {}
+ *     ListNode(int x) : val(x), next(nullptr) {}
+ *     ListNode(int x, ListNode *next) : val(x), next(next) {}
+ * };
+ */
+class Solution {
+public:
+    ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) {
+        ListNode*temp= new ListNode(-1);
+        ListNode*curr= temp;
+        int carry=0;
+        while(l1 or l2){
+            int n1= l1?l1->val:0;
+            int n2= l2?l2->val:0;
+            int sum= n1+n2+ carry;
+            carry= sum/10;
+            curr->next= new ListNode(sum%10);
+            curr= curr->next;
+            if(l1){
+                l1= l1->next;
+            }
+            if(l2){
+                l2= l2->next;
+            }
+            if(carry){
+                curr->next= new ListNode(carry);
+            }
+        }
+        return temp->next;
+    }
 };
\ No newline at end of file
diff --git a/ONLINE JUDGE/LeetCode/#328 Odd-Even-List.cpp b/ONLINE JUDGE/LeetCode/#328 Odd-Even-List.cpp
index ab840df..ff580da 100644
--- a/ONLINE JUDGE/LeetCode/#328 Odd-Even-List.cpp	
+++ b/ONLINE JUDGE/LeetCode/#328 Odd-Even-List.cpp	
@@ -1,29 +1,29 @@
-/**
- * Definition for singly-linked list.
- * struct ListNode {
- *     int val;
- *     ListNode *next;
- *     ListNode() : val(0), next(nullptr) {}
- *     ListNode(int x) : val(x), next(nullptr) {}
- *     ListNode(int x, ListNode *next) : val(x), next(next) {}
- * };
- */
-class Solution {
-public:
-    ListNode* oddEvenList(ListNode* head) {
-        if(head==NULL){
-            return NULL;
-        }
-        ListNode*oddIndex= head;
-        ListNode*evenIndex= head->next;
-        ListNode*evenHead=evenIndex;
-        while(evenIndex!=NULL and evenIndex->next!=NULL){
-            oddIndex->next= evenIndex->next;
-            oddIndex=oddIndex->next;
-            evenIndex->next= oddIndex->next;
-            evenIndex= evenIndex->next;
-        }
-        oddIndex->next= evenHead;
-        return head;
-    }
+/**
+ * Definition for singly-linked list.
+ * struct ListNode {
+ *     int val;
+ *     ListNode *next;
+ *     ListNode() : val(0), next(nullptr) {}
+ *     ListNode(int x) : val(x), next(nullptr) {}
+ *     ListNode(int x, ListNode *next) : val(x), next(next) {}
+ * };
+ */
+class Solution {
+public:
+    ListNode* oddEvenList(ListNode* head) {
+        if(head==NULL){
+            return NULL;
+        }
+        ListNode*oddIndex= head;
+        ListNode*evenIndex= head->next;
+        ListNode*evenHead=evenIndex;
+        while(evenIndex!=NULL and evenIndex->next!=NULL){
+            oddIndex->next= evenIndex->next;
+            oddIndex=oddIndex->next;
+            evenIndex->next= oddIndex->next;
+            evenIndex= evenIndex->next;
+        }
+        oddIndex->next= evenHead;
+        return head;
+    }
 };
\ No newline at end of file
diff --git a/ONLINE JUDGE/SPOJ/ACODE Alphacode.cpp b/ONLINE JUDGE/SPOJ/ACODE Alphacode.cpp
index 36ce103..77cceda 100644
--- a/ONLINE JUDGE/SPOJ/ACODE Alphacode.cpp	
+++ b/ONLINE JUDGE/SPOJ/ACODE Alphacode.cpp	
@@ -1,28 +1,28 @@
-#include<iostream>
-#include<string>
-using namespace std;
-
-int main()
-{
-    while(true)
-    {
-        string s;
-        cin>>s;
-        if((s[0])=='0')
-            break;
-        long long int memo[s.length()]={0};
-        memo[0]=1;
-        for(int i=1;i<s.length();i++)
-        {
-            if(s[i]!='0')
-                memo[i]=memo[i-1];
-            int num = ((s[i]-'0')+10*((s[i-1]-'0')));
-            if(num>=10&&num<=26&&i>1)
-                memo[i]+=memo[i-2];
-            else if(num>=10&&num<=26&&i==1)
-                memo[1]+=1;
-        }
-        cout<<memo[s.length()-1]<<endl;
-    }
-    return 0;
+#include<iostream>
+#include<string>
+using namespace std;
+
+int main()
+{
+    while(true)
+    {
+        string s;
+        cin>>s;
+        if((s[0])=='0')
+            break;
+        long long int memo[s.length()]={0};
+        memo[0]=1;
+        for(int i=1;i<s.length();i++)
+        {
+            if(s[i]!='0')
+                memo[i]=memo[i-1];
+            int num = ((s[i]-'0')+10*((s[i-1]-'0')));
+            if(num>=10&&num<=26&&i>1)
+                memo[i]+=memo[i-2];
+            else if(num>=10&&num<=26&&i==1)
+                memo[1]+=1;
+        }
+        cout<<memo[s.length()-1]<<endl;
+    }
+    return 0;
 }
\ No newline at end of file
diff --git a/ONLINE JUDGE/SPOJ/AGGRCOW Aggressive Cows.cpp b/ONLINE JUDGE/SPOJ/AGGRCOW Aggressive Cows.cpp
index 68f618c..8bc69c3 100644
--- a/ONLINE JUDGE/SPOJ/AGGRCOW Aggressive Cows.cpp	
+++ b/ONLINE JUDGE/SPOJ/AGGRCOW Aggressive Cows.cpp	
@@ -1,56 +1,56 @@
-#include<iostream>
-#include<vector>
-#include<algorithm>
-using namespace std;
-
-int checkDist(long long int maxdist,vector <long long int> arr, int c)
-{
-    int left=0;
-    c--;
-    for(int i=1;i<arr.size();i++)
-    {
-        if((arr[i]-arr[left])>=maxdist)
-        {
-            c--;
-            left=i;
-        }
-    }
-    if(c<=0)
-        return 1;
-    else
-        return 0;
-}
-int main()
-{
-    int t;
-    cin>>t;
-    while(t--)
-    {
-        int n,c;
-        cin>>n>>c;
-        vector <long long int> arr(n);
-        for(int i=0;i<n;i++)
-            cin>>arr[i];
-        sort(arr.begin(),arr.end());
-        int left = arr[0],right = arr[n-1];
-        long long int maxdist = left + (right-left)/2;
-        long long int ans=0;
-        while(left<=right)
-        {
-            //cout<<maxdist<<endl;
-            if(checkDist(maxdist,arr,c)==1)
-            {
-                if(maxdist>ans)
-                    ans=maxdist;
-                left=maxdist+1;
-                maxdist=left + (right-left)/2;
-            }
-            else
-            {
-                right = maxdist-1;
-                maxdist = left + (right-left)/2;
-            }
-        }
-        cout<<ans<<endl;
-    }
+#include<iostream>
+#include<vector>
+#include<algorithm>
+using namespace std;
+
+int checkDist(long long int maxdist,vector <long long int> arr, int c)
+{
+    int left=0;
+    c--;
+    for(int i=1;i<arr.size();i++)
+    {
+        if((arr[i]-arr[left])>=maxdist)
+        {
+            c--;
+            left=i;
+        }
+    }
+    if(c<=0)
+        return 1;
+    else
+        return 0;
+}
+int main()
+{
+    int t;
+    cin>>t;
+    while(t--)
+    {
+        int n,c;
+        cin>>n>>c;
+        vector <long long int> arr(n);
+        for(int i=0;i<n;i++)
+            cin>>arr[i];
+        sort(arr.begin(),arr.end());
+        int left = arr[0],right = arr[n-1];
+        long long int maxdist = left + (right-left)/2;
+        long long int ans=0;
+        while(left<=right)
+        {
+            //cout<<maxdist<<endl;
+            if(checkDist(maxdist,arr,c)==1)
+            {
+                if(maxdist>ans)
+                    ans=maxdist;
+                left=maxdist+1;
+                maxdist=left + (right-left)/2;
+            }
+            else
+            {
+                right = maxdist-1;
+                maxdist = left + (right-left)/2;
+            }
+        }
+        cout<<ans<<endl;
+    }
 }
\ No newline at end of file
diff --git a/ONLINE JUDGE/SPOJ/GSS1 Can you answer these queries I.cpp b/ONLINE JUDGE/SPOJ/GSS1 Can you answer these queries I.cpp
index 5e0ddd8..075efd6 100644
--- a/ONLINE JUDGE/SPOJ/GSS1 Can you answer these queries I.cpp	
+++ b/ONLINE JUDGE/SPOJ/GSS1 Can you answer these queries I.cpp	
@@ -1,92 +1,92 @@
-#include<bits/stdc++.h>
-using namespace std;
-#define inf 0x3f3f 
-
-struct Node { 
-    int maxPrefixSum; 
-    int maxSuffixSum; 
-    int totalSum; 
-    int maxSubarraySum; 
-   
-    Node() 
-    { 
-        maxPrefixSum = maxSuffixSum = maxSubarraySum = -inf; 
-        totalSum = -inf; 
-    } 
-};
-Node merge(Node left, Node right)
-{
-    Node parent;
-    parent.maxPrefixSum = max(left.maxPrefixSum,left.totalSum+right.maxPrefixSum);
-    parent.maxSuffixSum = max(right.maxSuffixSum, right.totalSum+left.maxSuffixSum);
-    parent.totalSum = left.totalSum+right.totalSum;
-    parent.maxSubarraySum = max({left.maxSubarraySum,right.maxSubarraySum,left.maxSuffixSum+right.maxPrefixSum});
-    return parent;
-}
-void construct_tree_util(Node*tree, int arr[], int low, int high, int pos)
-{
-    if(low==high)
-    {
-        tree[pos].maxPrefixSum=arr[low];
-        tree[pos].maxSuffixSum=arr[low];
-        tree[pos].totalSum=arr[low];
-        tree[pos].maxSubarraySum=arr[low];
-        return;
-    }
-    int mid = (low+high)/2;
-    construct_tree_util(tree,arr,low,mid,2*pos);
-    construct_tree_util(tree,arr, mid+1,high,2*pos+1);
-    tree[pos] = merge(tree[2*pos],tree[2*pos+1]);
-}
-Node* construct_tree(int arr[],int n)
-{
-    
-    int seglen;
-    if((ceil(log2(n))==floor(log2(n))))
-        seglen = n*2-1;
-    else
-        seglen = pow(2,(ceil(log2(n))))*2-1;
-    Node* tree = new Node[seglen];
-    construct_tree_util(tree,arr,0,n-1,1);
-    return tree;
-}
-
-Node solveQueryUtil(Node*tree, int low, int high, int qlow, int qhigh, int pos)
-{
-    if(high<qlow||qhigh<low)
-    {
-        Node nullnode;
-        return nullnode;
-    }
-    if(low>=qlow&&qhigh>=high)
-        return tree[pos];
-    int mid = (low + high)/2; 
-    Node left = solveQueryUtil(tree, low, mid, qlow, qhigh, 2*pos); 
-    Node right = solveQueryUtil(tree, mid + 1, high, qlow, qhigh, 2*pos + 1);  
-    Node res = merge(left, right); 
-    return res; 
-}
-int solveQuery(Node* tree, int low, int high, int n)
-{
-    Node res = solveQueryUtil(tree, 0, n - 1, low, high, 1); 
-    return res.maxSubarraySum; 
-}
-
-int main()
-{
-    int n;
-    cin>>n;
-    int arr[n];
-    for(int i=0;i<n;i++)
-        cin>>arr[i];
-    Node* tree = construct_tree(arr,n);
-    int m;
-    cin>>m;
-    while(m--)
-    {
-        int x,y;
-        cin>>x>>y;
-        cout<<solveQuery(tree,x-1,y-1,n)<<endl;
-    }
-    return 0;
+#include<bits/stdc++.h>
+using namespace std;
+#define inf 0x3f3f 
+
+struct Node { 
+    int maxPrefixSum; 
+    int maxSuffixSum; 
+    int totalSum; 
+    int maxSubarraySum; 
+   
+    Node() 
+    { 
+        maxPrefixSum = maxSuffixSum = maxSubarraySum = -inf; 
+        totalSum = -inf; 
+    } 
+};
+Node merge(Node left, Node right)
+{
+    Node parent;
+    parent.maxPrefixSum = max(left.maxPrefixSum,left.totalSum+right.maxPrefixSum);
+    parent.maxSuffixSum = max(right.maxSuffixSum, right.totalSum+left.maxSuffixSum);
+    parent.totalSum = left.totalSum+right.totalSum;
+    parent.maxSubarraySum = max({left.maxSubarraySum,right.maxSubarraySum,left.maxSuffixSum+right.maxPrefixSum});
+    return parent;
+}
+void construct_tree_util(Node*tree, int arr[], int low, int high, int pos)
+{
+    if(low==high)
+    {
+        tree[pos].maxPrefixSum=arr[low];
+        tree[pos].maxSuffixSum=arr[low];
+        tree[pos].totalSum=arr[low];
+        tree[pos].maxSubarraySum=arr[low];
+        return;
+    }
+    int mid = (low+high)/2;
+    construct_tree_util(tree,arr,low,mid,2*pos);
+    construct_tree_util(tree,arr, mid+1,high,2*pos+1);
+    tree[pos] = merge(tree[2*pos],tree[2*pos+1]);
+}
+Node* construct_tree(int arr[],int n)
+{
+    
+    int seglen;
+    if((ceil(log2(n))==floor(log2(n))))
+        seglen = n*2-1;
+    else
+        seglen = pow(2,(ceil(log2(n))))*2-1;
+    Node* tree = new Node[seglen];
+    construct_tree_util(tree,arr,0,n-1,1);
+    return tree;
+}
+
+Node solveQueryUtil(Node*tree, int low, int high, int qlow, int qhigh, int pos)
+{
+    if(high<qlow||qhigh<low)
+    {
+        Node nullnode;
+        return nullnode;
+    }
+    if(low>=qlow&&qhigh>=high)
+        return tree[pos];
+    int mid = (low + high)/2; 
+    Node left = solveQueryUtil(tree, low, mid, qlow, qhigh, 2*pos); 
+    Node right = solveQueryUtil(tree, mid + 1, high, qlow, qhigh, 2*pos + 1);  
+    Node res = merge(left, right); 
+    return res; 
+}
+int solveQuery(Node* tree, int low, int high, int n)
+{
+    Node res = solveQueryUtil(tree, 0, n - 1, low, high, 1); 
+    return res.maxSubarraySum; 
+}
+
+int main()
+{
+    int n;
+    cin>>n;
+    int arr[n];
+    for(int i=0;i<n;i++)
+        cin>>arr[i];
+    Node* tree = construct_tree(arr,n);
+    int m;
+    cin>>m;
+    while(m--)
+    {
+        int x,y;
+        cin>>x>>y;
+        cout<<solveQuery(tree,x-1,y-1,n)<<endl;
+    }
+    return 0;
 }
\ No newline at end of file
diff --git a/ONLINE JUDGE/SPOJ/HORRIBLE Horrible Queries.cpp b/ONLINE JUDGE/SPOJ/HORRIBLE Horrible Queries.cpp
index ba96767..8dfa4ba 100644
--- a/ONLINE JUDGE/SPOJ/HORRIBLE Horrible Queries.cpp	
+++ b/ONLINE JUDGE/SPOJ/HORRIBLE Horrible Queries.cpp	
@@ -1,102 +1,102 @@
-#include<bits/stdc++.h>
-using namespace std;
-
-long long int tree[400001]={0};
-long long int lazy[400001]={0};
-
-void updateRange(long long int ss, long long int se, long long int us, long long int ue, long long int diff, long long int si)
-{
-    if(lazy[si]!=0)
-    {
-        tree[si] += (se-ss+1)*lazy[si];
-        if(se!=ss)
-        {
-            lazy[2*si+1]+=lazy[si];
-            lazy[2*si+2]+=lazy[si];
-        }
-        lazy[si]=0;
-    }
-    if(ss>se||ss>ue||se<us)
-        return;
-    if(us<=ss&&ue>=se)
-    {
-        tree[si]+= (se-ss+1)*diff;
-        if(ss!=se)
-        {
-            lazy[2*si+1] += diff;
-            lazy[2*si+2] += diff; 
-        }
-        return;
-    }
-    long long int mid = ss + (se-ss)/2;
-    updateRange(ss,mid,us,ue,diff,2*si+1);
-    updateRange(mid+1,se,us,ue,diff,2*si+2);
-    tree[si] = tree[2*si+1]+tree[2*si+2];
-}
-long long int getSum(long long int ss, long long int se, long long int qs, long long int qe, long long int si)
-{
-    if(lazy[si]!=0)
-    {
-        tree[si] += (se-ss+1)*lazy[si];
-        if(se!=ss)
-        {
-            lazy[2*si+1]+=lazy[si];
-            lazy[2*si+2]+=lazy[si];
-        }
-        lazy[si]=0;
-    }
-    if(ss>se||ss>qe||se<qs)
-        return 0;
-    if(qs<=ss&&qe>=se)
-        return tree[si];
-    long long int mid = ss + (se-ss)/2;
-    return getSum(ss,mid,qs,qe,2*si+1)+getSum(mid+1,se,qs,qe,2*si+2);
-}
-void constructTreeUtil(long long int arr[], long long int ss, long long int se, long long int si)
-{
-    if(ss>se)
-        return;
-    if(ss==se)
-    {
-        tree[si]=arr[ss];
-        return;
-    }
-    long long int mid = ss + (se-ss)/2;
-    constructTreeUtil(arr,ss,mid,2*si+1);
-    constructTreeUtil(arr,mid+1,se,2*si+2);
-    tree[si] = tree[2*si+1]+tree[2*si+2];
-}
-void constructTree(long long int arr[], long long int n)
-{
-    constructTreeUtil(arr,0,n-1,0);
-}
-int main()
-{
-    long long int t;
-    cin>>t;
-    while(t--)
-    {
-        long long int n,c;
-        cin>>n>>c;
-        long long int arr[n] = {0};
-        memset(tree,0,sizeof(tree));
-        memset(lazy,0,sizeof(tree));
-        constructTree(arr,n);
-        for(long long int i=0;i<c;i++)
-        {
-            long long int flag,p,q,v;
-            cin>>flag;
-            if(flag==0)
-            {
-                cin>>p>>q>>v;
-                updateRange(0,n-1,p-1,q-1,v,0);
-            }
-            else
-            {
-                cin>>p>>q;
-                cout<<getSum(0,n-1,p-1,q-1,0)<<endl;
-            }   
-        }
-    }
-    return 0;
+#include<bits/stdc++.h>
+using namespace std;
+
+long long int tree[400001]={0};
+long long int lazy[400001]={0};
+
+void updateRange(long long int ss, long long int se, long long int us, long long int ue, long long int diff, long long int si)
+{
+    if(lazy[si]!=0)
+    {
+        tree[si] += (se-ss+1)*lazy[si];
+        if(se!=ss)
+        {
+            lazy[2*si+1]+=lazy[si];
+            lazy[2*si+2]+=lazy[si];
+        }
+        lazy[si]=0;
+    }
+    if(ss>se||ss>ue||se<us)
+        return;
+    if(us<=ss&&ue>=se)
+    {
+        tree[si]+= (se-ss+1)*diff;
+        if(ss!=se)
+        {
+            lazy[2*si+1] += diff;
+            lazy[2*si+2] += diff; 
+        }
+        return;
+    }
+    long long int mid = ss + (se-ss)/2;
+    updateRange(ss,mid,us,ue,diff,2*si+1);
+    updateRange(mid+1,se,us,ue,diff,2*si+2);
+    tree[si] = tree[2*si+1]+tree[2*si+2];
+}
+long long int getSum(long long int ss, long long int se, long long int qs, long long int qe, long long int si)
+{
+    if(lazy[si]!=0)
+    {
+        tree[si] += (se-ss+1)*lazy[si];
+        if(se!=ss)
+        {
+            lazy[2*si+1]+=lazy[si];
+            lazy[2*si+2]+=lazy[si];
+        }
+        lazy[si]=0;
+    }
+    if(ss>se||ss>qe||se<qs)
+        return 0;
+    if(qs<=ss&&qe>=se)
+        return tree[si];
+    long long int mid = ss + (se-ss)/2;
+    return getSum(ss,mid,qs,qe,2*si+1)+getSum(mid+1,se,qs,qe,2*si+2);
+}
+void constructTreeUtil(long long int arr[], long long int ss, long long int se, long long int si)
+{
+    if(ss>se)
+        return;
+    if(ss==se)
+    {
+        tree[si]=arr[ss];
+        return;
+    }
+    long long int mid = ss + (se-ss)/2;
+    constructTreeUtil(arr,ss,mid,2*si+1);
+    constructTreeUtil(arr,mid+1,se,2*si+2);
+    tree[si] = tree[2*si+1]+tree[2*si+2];
+}
+void constructTree(long long int arr[], long long int n)
+{
+    constructTreeUtil(arr,0,n-1,0);
+}
+int main()
+{
+    long long int t;
+    cin>>t;
+    while(t--)
+    {
+        long long int n,c;
+        cin>>n>>c;
+        long long int arr[n] = {0};
+        memset(tree,0,sizeof(tree));
+        memset(lazy,0,sizeof(tree));
+        constructTree(arr,n);
+        for(long long int i=0;i<c;i++)
+        {
+            long long int flag,p,q,v;
+            cin>>flag;
+            if(flag==0)
+            {
+                cin>>p>>q>>v;
+                updateRange(0,n-1,p-1,q-1,v,0);
+            }
+            else
+            {
+                cin>>p>>q;
+                cout<<getSum(0,n-1,p-1,q-1,0)<<endl;
+            }   
+        }
+    }
+    return 0;
 }
\ No newline at end of file
diff --git a/ONLINE JUDGE/SPOJ/INVCNT Inversion Count.cpp b/ONLINE JUDGE/SPOJ/INVCNT Inversion Count.cpp
index 2fce06f..8215043 100644
--- a/ONLINE JUDGE/SPOJ/INVCNT Inversion Count.cpp	
+++ b/ONLINE JUDGE/SPOJ/INVCNT Inversion Count.cpp	
@@ -1,66 +1,66 @@
-#include<iostream>
-#include<vector>
-using namespace std;
-typedef long long int LL;
-
-LL merge(vector<LL> &arr, vector<LL> &temp, LL l, LL m, LL r)
-{
-    LL i=l,j=m,k=l,inv=0;
-    //vector<LL> temp(arr.size());
-    while(i<m&&j<=r)
-    {
-        if(arr[i]<arr[j])
-            temp[k++]=arr[i++];
-        else if(arr[i]==arr[j])
-        {
-            temp[k++]=arr[i++];
-            j++;
-        }
-        else
-        {
-            temp[k++]=arr[j++];
-            inv += (m-i);
-        }
-
-    }
-    while(i<m)
-        temp[k++]=arr[i++];
-    while(j<=r)
-        temp[k++]=arr[j++];
-    for(LL p=l;p<=r;p++)
-        arr[p]=temp[p];
-    return inv;
-}
-LL mergesort(vector<LL> &arr,vector<LL> &temp, LL l, LL r)
-{
-    LL inv=0;
-    if(l<r)
-    {
-        LL mid = (l+r)/2;
-        inv += mergesort(arr,temp,l,mid);
-        inv += mergesort(arr,temp,mid+1,r);
-        inv += merge(arr,temp,l,mid+1,r);
-    }
-    return inv;
-}
-LL _mergesort(vector<LL> arr,LL n)
-{
-    vector<LL> temp(n);
-    return mergesort(arr,temp,0,n-1);
-}
-int main()
-{
-    LL t;
-    cin>>t;
-    while(t--)
-    {
-        LL n;
-        cin>>n;
-        vector<LL> arr(n);
-        for(LL i=0;i<n;i++)
-            cin>>arr[i];
-        LL inv = _mergesort(arr,n);
-        cout<<inv<<endl;
-    }
-    return 0;
+#include<iostream>
+#include<vector>
+using namespace std;
+typedef long long int LL;
+
+LL merge(vector<LL> &arr, vector<LL> &temp, LL l, LL m, LL r)
+{
+    LL i=l,j=m,k=l,inv=0;
+    //vector<LL> temp(arr.size());
+    while(i<m&&j<=r)
+    {
+        if(arr[i]<arr[j])
+            temp[k++]=arr[i++];
+        else if(arr[i]==arr[j])
+        {
+            temp[k++]=arr[i++];
+            j++;
+        }
+        else
+        {
+            temp[k++]=arr[j++];
+            inv += (m-i);
+        }
+
+    }
+    while(i<m)
+        temp[k++]=arr[i++];
+    while(j<=r)
+        temp[k++]=arr[j++];
+    for(LL p=l;p<=r;p++)
+        arr[p]=temp[p];
+    return inv;
+}
+LL mergesort(vector<LL> &arr,vector<LL> &temp, LL l, LL r)
+{
+    LL inv=0;
+    if(l<r)
+    {
+        LL mid = (l+r)/2;
+        inv += mergesort(arr,temp,l,mid);
+        inv += mergesort(arr,temp,mid+1,r);
+        inv += merge(arr,temp,l,mid+1,r);
+    }
+    return inv;
+}
+LL _mergesort(vector<LL> arr,LL n)
+{
+    vector<LL> temp(n);
+    return mergesort(arr,temp,0,n-1);
+}
+int main()
+{
+    LL t;
+    cin>>t;
+    while(t--)
+    {
+        LL n;
+        cin>>n;
+        vector<LL> arr(n);
+        for(LL i=0;i<n;i++)
+            cin>>arr[i];
+        LL inv = _mergesort(arr,n);
+        cout<<inv<<endl;
+    }
+    return 0;
 }
\ No newline at end of file
diff --git a/ONLINE JUDGE/SPOJ/JULKA Julka.cpp b/ONLINE JUDGE/SPOJ/JULKA Julka.cpp
index 7d56bc8..b71827f 100644
--- a/ONLINE JUDGE/SPOJ/JULKA Julka.cpp	
+++ b/ONLINE JUDGE/SPOJ/JULKA Julka.cpp	
@@ -1,101 +1,101 @@
-#include<bits/stdc++.h>
-using namespace std;
-
-string findDiff(string str1, string str2) 
-{ 
-    string str = ""; 
-    int n1 = str1.length(), n2 = str2.length(); 
-    int diff = n1 - n2;  
-    int carry = 0; 
-  
-    for (int i=n2-1; i>=0; i--) 
-    { 
-        int sub = ((str1[i+diff]-'0') - (str2[i]-'0') - carry); 
-        if (sub < 0) 
-        { 
-            sub = sub+10; 
-            carry = 1; 
-        } 
-        else
-            carry = 0; 
-  
-        str.push_back(sub + '0'); 
-    } 
-    for (int i=n1-n2-1; i>=0; i--) 
-    { 
-        if (str1[i]=='0' && carry) 
-        { 
-            str.push_back('9'); 
-            continue; 
-        } 
-        int sub = ((str1[i]-'0') - carry); 
-        if (i>0 || sub>0)
-            str.push_back(sub+'0'); 
-        carry = 0; 
-  
-    } 
-    reverse(str.begin(), str.end()); 
-    return str; 
-} 
- 
-string findSum(string str1, string str2) 
-{ 
-    string str = ""; 
-    if (str1.length() > str2.length()) 
-        swap(str1, str2); 
-    int n1 = str1.length(), n2 = str2.length(); 
-
-    reverse(str1.begin(), str1.end()); 
-    reverse(str2.begin(), str2.end()); 
-  
-    int carry = 0; 
-    for (int i=0; i<n1; i++) 
-    { 
-        int sum = ((str1[i]-'0')+(str2[i]-'0')+carry); 
-        str.push_back(sum%10 + '0'); 
-        carry = sum/10; 
-    } 
-  
-    for (int i=n1; i<n2; i++) 
-    { 
-        int sum = ((str2[i]-'0')+carry); 
-        str.push_back(sum%10 + '0'); 
-        carry = sum/10; 
-    } 
-  
-    if (carry) 
-        str.push_back(carry+'0'); 
- 
-    reverse(str.begin(), str.end()); 
-  
-    return str; 
-}
-string longDivision(string number, int divisor) 
-{ 
-    string ans; 
-    int idx = 0; 
-    int temp = number[idx] - '0'; 
-    while (temp < divisor) 
-        temp = temp * 10 + (number[++idx] - '0'); 
-  
-    while (number.size() > idx) { 
-        ans += (temp / divisor) + '0'; 
-        temp = (temp % divisor) * 10 + number[++idx] - '0'; 
-    } 
-    if (ans.length() == 0) 
-        return "0"; 
-    return ans; 
-}
-int main()
-{
-    int t=10;
-    while(t--)
-    {
-        string a,b,x,y;
-        cin>>a>>b;
-        x=findSum(a,b);
-        y=findDiff(a,b);
-        cout<<longDivision(x,2)<<endl<<longDivision(y,2)<<endl;
-    }
-    return 0;
+#include<bits/stdc++.h>
+using namespace std;
+
+string findDiff(string str1, string str2) 
+{ 
+    string str = ""; 
+    int n1 = str1.length(), n2 = str2.length(); 
+    int diff = n1 - n2;  
+    int carry = 0; 
+  
+    for (int i=n2-1; i>=0; i--) 
+    { 
+        int sub = ((str1[i+diff]-'0') - (str2[i]-'0') - carry); 
+        if (sub < 0) 
+        { 
+            sub = sub+10; 
+            carry = 1; 
+        } 
+        else
+            carry = 0; 
+  
+        str.push_back(sub + '0'); 
+    } 
+    for (int i=n1-n2-1; i>=0; i--) 
+    { 
+        if (str1[i]=='0' && carry) 
+        { 
+            str.push_back('9'); 
+            continue; 
+        } 
+        int sub = ((str1[i]-'0') - carry); 
+        if (i>0 || sub>0)
+            str.push_back(sub+'0'); 
+        carry = 0; 
+  
+    } 
+    reverse(str.begin(), str.end()); 
+    return str; 
+} 
+ 
+string findSum(string str1, string str2) 
+{ 
+    string str = ""; 
+    if (str1.length() > str2.length()) 
+        swap(str1, str2); 
+    int n1 = str1.length(), n2 = str2.length(); 
+
+    reverse(str1.begin(), str1.end()); 
+    reverse(str2.begin(), str2.end()); 
+  
+    int carry = 0; 
+    for (int i=0; i<n1; i++) 
+    { 
+        int sum = ((str1[i]-'0')+(str2[i]-'0')+carry); 
+        str.push_back(sum%10 + '0'); 
+        carry = sum/10; 
+    } 
+  
+    for (int i=n1; i<n2; i++) 
+    { 
+        int sum = ((str2[i]-'0')+carry); 
+        str.push_back(sum%10 + '0'); 
+        carry = sum/10; 
+    } 
+  
+    if (carry) 
+        str.push_back(carry+'0'); 
+ 
+    reverse(str.begin(), str.end()); 
+  
+    return str; 
+}
+string longDivision(string number, int divisor) 
+{ 
+    string ans; 
+    int idx = 0; 
+    int temp = number[idx] - '0'; 
+    while (temp < divisor) 
+        temp = temp * 10 + (number[++idx] - '0'); 
+  
+    while (number.size() > idx) { 
+        ans += (temp / divisor) + '0'; 
+        temp = (temp % divisor) * 10 + number[++idx] - '0'; 
+    } 
+    if (ans.length() == 0) 
+        return "0"; 
+    return ans; 
+}
+int main()
+{
+    int t=10;
+    while(t--)
+    {
+        string a,b,x,y;
+        cin>>a>>b;
+        x=findSum(a,b);
+        y=findDiff(a,b);
+        cout<<longDivision(x,2)<<endl<<longDivision(y,2)<<endl;
+    }
+    return 0;
 }
\ No newline at end of file
diff --git a/ONLINE JUDGE/SPOJ/PALIN The next Palindrome.cpp b/ONLINE JUDGE/SPOJ/PALIN The next Palindrome.cpp
index 5fa25bd..283de07 100644
--- a/ONLINE JUDGE/SPOJ/PALIN The next Palindrome.cpp	
+++ b/ONLINE JUDGE/SPOJ/PALIN The next Palindrome.cpp	
@@ -1,78 +1,78 @@
-#include<bits/stdc++.h>
-using namespace std;
-
-string allnine(string s, int len)
-{
-    string result(1, '1');
-    for(int i=1;i<=len-1;i++)
-        result+='0';
-    result += '1';
-    return result;
-}
-
-string findPalindrome(string s, int len)
-{
-    string left,right,result;
-    left = s.substr(0,len/2);
-    if(len%2!=0)
-        right = s.substr(len/2+1,len/2);
-    else
-        right = s.substr(len/2,len/2);
-    int sublen = left.length();
-    for(int i=sublen-1,j=0;i>=0,j<sublen;i--,j++)
-    {
-        if((left[i]-'0')==(right[j]-'0'))
-            continue;
-        if((left[i]-'0')>(right[j]-'0'))
-        {
-            result=left;
-            string rev(result.rbegin(),result.rend());
-            if(len%2!=0)
-                result+= s[len/2];
-            result += rev;
-            return result;
-        }
-        if((left[i]-'0')<(right[j]-'0'))
-            break;
-    }
-    int carry=0;
-    for(int i=ceil(float(len)/2)-1;i>=0;i--)
-    {
-        int x = s[i]-'0';
-        if(i==(ceil(float(len)/2)-1))
-            x=x+1;
-        if(carry)
-            x = x+carry;
-        carry = x/10;
-        x=x%10;
-        s[i]=x+'0';
-        s[len-i-1]=x+'0';
-    }
-    return s;
-}
-
-int main()
-{
-    long long int t;
-    cin>>t;
-    string one(1,'1');
-    while(t--)
-    {
-        string str,result;
-        cin>>str;
-        str.erase(0, min(str.find_first_not_of('0'), str.size()-1));
-        int flag=0,len=str.length();
-        for(int i=0;i<len;i++)
-            if(str[i]!='9')
-                flag=1;
-        if(flag==0)
-        {
-            result = allnine(str,len);
-            cout<<result<<endl;
-            continue;
-        }
-        result = findPalindrome(str,len);
-        cout<<result<<endl;
-    }
-    return 0;
+#include<bits/stdc++.h>
+using namespace std;
+
+string allnine(string s, int len)
+{
+    string result(1, '1');
+    for(int i=1;i<=len-1;i++)
+        result+='0';
+    result += '1';
+    return result;
+}
+
+string findPalindrome(string s, int len)
+{
+    string left,right,result;
+    left = s.substr(0,len/2);
+    if(len%2!=0)
+        right = s.substr(len/2+1,len/2);
+    else
+        right = s.substr(len/2,len/2);
+    int sublen = left.length();
+    for(int i=sublen-1,j=0;i>=0,j<sublen;i--,j++)
+    {
+        if((left[i]-'0')==(right[j]-'0'))
+            continue;
+        if((left[i]-'0')>(right[j]-'0'))
+        {
+            result=left;
+            string rev(result.rbegin(),result.rend());
+            if(len%2!=0)
+                result+= s[len/2];
+            result += rev;
+            return result;
+        }
+        if((left[i]-'0')<(right[j]-'0'))
+            break;
+    }
+    int carry=0;
+    for(int i=ceil(float(len)/2)-1;i>=0;i--)
+    {
+        int x = s[i]-'0';
+        if(i==(ceil(float(len)/2)-1))
+            x=x+1;
+        if(carry)
+            x = x+carry;
+        carry = x/10;
+        x=x%10;
+        s[i]=x+'0';
+        s[len-i-1]=x+'0';
+    }
+    return s;
+}
+
+int main()
+{
+    long long int t;
+    cin>>t;
+    string one(1,'1');
+    while(t--)
+    {
+        string str,result;
+        cin>>str;
+        str.erase(0, min(str.find_first_not_of('0'), str.size()-1));
+        int flag=0,len=str.length();
+        for(int i=0;i<len;i++)
+            if(str[i]!='9')
+                flag=1;
+        if(flag==0)
+        {
+            result = allnine(str,len);
+            cout<<result<<endl;
+            continue;
+        }
+        result = findPalindrome(str,len);
+        cout<<result<<endl;
+    }
+    return 0;
 }
\ No newline at end of file
diff --git a/ONLINE JUDGE/SPOJ/PRIME1 Prime Generator.cpp b/ONLINE JUDGE/SPOJ/PRIME1 Prime Generator.cpp
index 03c5147..6bf4c31 100644
--- a/ONLINE JUDGE/SPOJ/PRIME1 Prime Generator.cpp	
+++ b/ONLINE JUDGE/SPOJ/PRIME1 Prime Generator.cpp	
@@ -1,29 +1,29 @@
-#include<iostream>
-#include<cmath>
-using namespace std;
-
-int main()
-{
-    int t;
-    cin>>t;
-    while(t--)
-    {
-        long int m,n;
-        cin>>m>>n;
-        for(int i=m;i<=n;i++)
-        {   
-            int flag=0;
-            for(int j=2;j<=sqrt(i);j++)
-            {
-                if(i%j==0)
-                {
-                    flag=1;
-                    break;
-                }
-            }
-            if(!flag&&i>=2)
-                cout<<i<<endl;
-        }
-    }
-    cout<<endl;
+#include<iostream>
+#include<cmath>
+using namespace std;
+
+int main()
+{
+    int t;
+    cin>>t;
+    while(t--)
+    {
+        long int m,n;
+        cin>>m>>n;
+        for(int i=m;i<=n;i++)
+        {   
+            int flag=0;
+            for(int j=2;j<=sqrt(i);j++)
+            {
+                if(i%j==0)
+                {
+                    flag=1;
+                    break;
+                }
+            }
+            if(!flag&&i>=2)
+                cout<<i<<endl;
+        }
+    }
+    cout<<endl;
 }
\ No newline at end of file

From 712be27f393287cfdbc219a2a15d3a1eef158aac Mon Sep 17 00:00:00 2001
From: Gunish Jain <41867768+gunishjain@users.noreply.github.com>
Date: Sun, 4 Oct 2020 15:33:11 +0530
Subject: [PATCH 044/203] Added Josephus Problem

---
 .../JosephusProblem.cpp                       | 23 +++++++++++++++++++
 1 file changed, 23 insertions(+)
 create mode 100644 10- Recursion & Backtracking/JosephusProblem.cpp

diff --git a/10- Recursion & Backtracking/JosephusProblem.cpp b/10- Recursion & Backtracking/JosephusProblem.cpp
new file mode 100644
index 0000000..8b6f90a
--- /dev/null
+++ b/10- Recursion & Backtracking/JosephusProblem.cpp	
@@ -0,0 +1,23 @@
+#include <iostream>
+using namespace std;
+
+
+int jos(int n, int k)
+{
+	if(n == 1)
+		return 0;
+	else
+		return (jos(n - 1, k) + k) % n;
+}
+
+int myJos(int n, int k)
+{
+	return jos(n, k) + 1;
+}
+	
+int main() {
+	
+	cout<<myJos(5, 3); 
+	
+	return 0;
+}
\ No newline at end of file

From 92a04ccca32615d430d5edd551f0abf11e4a5f74 Mon Sep 17 00:00:00 2001
From: ajay <ajay17599@gmail.com>
Date: Sun, 4 Oct 2020 21:29:21 +0530
Subject: [PATCH 045/203] #384 Shuffle An Array added

---
 .../LeetCode/#384-Shuffle-An-Array.cpp        | 35 +++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#384-Shuffle-An-Array.cpp

diff --git a/ONLINE JUDGE/LeetCode/#384-Shuffle-An-Array.cpp b/ONLINE JUDGE/LeetCode/#384-Shuffle-An-Array.cpp
new file mode 100644
index 0000000..cab1d16
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#384-Shuffle-An-Array.cpp	
@@ -0,0 +1,35 @@
+/**
+ * Your Solution object will be instantiated and called as such:
+ * Solution* obj = new Solution(nums);
+ * vector<int> param_1 = obj->reset();
+ * vector<int> param_2 = obj->shuffle();
+ */
+class Solution
+{
+private:
+    vector<int> temp, original;
+
+public:
+    Solution(vector<int> &nums)
+    {
+        temp = nums;
+        original = nums;
+    }
+
+    /** Resets the array to its original configuration and return it. */
+    vector<int> reset()
+    {
+        return temp = original;
+    }
+
+    /** Returns a random shuffling of the array. */
+    vector<int> shuffle()
+    {
+        for (int i = temp.size() - 1; i >= 0; i--)
+        {
+            int idx = rand() % (i + 1);
+            swap(temp[i], temp[idx]);
+        }
+        return temp;
+    }
+};
\ No newline at end of file

From c1ed1e6df78b24b84f119f63d0c7629e652d1073 Mon Sep 17 00:00:00 2001
From: kross9924 <kross9924@gmail.com>
Date: Sun, 4 Oct 2020 22:13:21 +0530
Subject: [PATCH 046/203] add solution to leetcode problem #1461

---
 ...ng_contains_all_binary_codes_of_size_k.cpp | 21 +++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#1461-check_if_a_string_contains_all_binary_codes_of_size_k.cpp

diff --git a/ONLINE JUDGE/LeetCode/#1461-check_if_a_string_contains_all_binary_codes_of_size_k.cpp b/ONLINE JUDGE/LeetCode/#1461-check_if_a_string_contains_all_binary_codes_of_size_k.cpp
new file mode 100644
index 0000000..022657b
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#1461-check_if_a_string_contains_all_binary_codes_of_size_k.cpp	
@@ -0,0 +1,21 @@
+class Solution {
+public:
+    bool hasAllCodes(string s, int k) {
+        int need = 1<<k;
+        vector<bool> got(need);
+        int allOne = need - 1;
+        int hashVal = 0;
+        for(int i = 0 ; i < s.length() ; i++) {
+            //calculate hash for s.substr(i-k+1,i+1)
+            hashVal = ((hashVal << 1) & allOne) | (s[i] - '0');
+            if(i >= k - 1 && !got[hashVal]){
+                got[hashVal] = true;
+                need--;
+                if (need == 0){
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+};

From cf4fe29162acb26f987a60c81ef6e7340b6dca50 Mon Sep 17 00:00:00 2001
From: Mohit saha <52305250+mohitsaha@users.noreply.github.com>
Date: Sun, 4 Oct 2020 23:04:48 +0530
Subject: [PATCH 047/203] Created #20-valid-Parentheses

frequently asked question
---
 .../LeetCode/#20-Valid-Parentheses.cpp        | 48 +++++++++++++++++++
 1 file changed, 48 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#20-Valid-Parentheses.cpp

diff --git a/ONLINE JUDGE/LeetCode/#20-Valid-Parentheses.cpp b/ONLINE JUDGE/LeetCode/#20-Valid-Parentheses.cpp
new file mode 100644
index 0000000..be35a5a
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#20-Valid-Parentheses.cpp	
@@ -0,0 +1,48 @@
+/*
+Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.
+
+An input string is valid if:
+
+Open brackets must be closed by the same type of brackets.
+Open brackets must be closed in the correct order.
+*/
+//implementation through stack
+class Solution {
+public:
+    bool isValid(string s) {
+        stack<char>stk;
+        int f = 1;
+        for(int i = 0; i < s.length(); i++)
+        {
+            if(s[i] == '{' || s[i] == '[' || s[i] == '(')
+            {   
+                stk.push(s[i]);
+            }
+            else
+            {
+                if(stk.empty())
+                {
+                    f = 0;
+                    break;
+                }
+                char open_bracket = stk.top();
+                if((s[i] == (open_bracket + 1)) || (s[i] == (open_bracket + 2)))
+                {
+                    stk.pop();
+                }
+                else{
+                    f = 0;
+                    break;
+                }
+            }
+        }
+        if(f == 1 && stk.empty())
+        {
+            return true;
+        }
+        else
+        {
+            return false;
+        }
+    }
+};

From b778d1ec876e70e5d76d7fa4fb461232bd6d946b Mon Sep 17 00:00:00 2001
From: Mohit saha <52305250+mohitsaha@users.noreply.github.com>
Date: Sun, 4 Oct 2020 23:18:26 +0530
Subject: [PATCH 048/203] Created #33-Search-in-Rotated-Sorted-Array.cpp

added famous binary search question
---
 .../#33-Search-in-Rotated-Sorted-Array.cpp    | 41 +++++++++++++++++++
 1 file changed, 41 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#33-Search-in-Rotated-Sorted-Array.cpp

diff --git a/ONLINE JUDGE/LeetCode/#33-Search-in-Rotated-Sorted-Array.cpp b/ONLINE JUDGE/LeetCode/#33-Search-in-Rotated-Sorted-Array.cpp
new file mode 100644
index 0000000..0dac0dd
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#33-Search-in-Rotated-Sorted-Array.cpp	
@@ -0,0 +1,41 @@
+class Solution {
+public:
+    int search(vector<int>& nums, int target) 
+    {
+        int n=nums.size();
+        int index=-1, low=0, high=n-1;
+        while(low<=high)
+        {
+            int mid = low+(high-low)/2;
+            if(mid>0 && nums[mid]<nums[mid-1]) 
+            {
+                index = mid-1;
+                break;
+            }
+            if(mid<n-1 && nums[mid]>nums[mid+1])
+            {
+                index = mid;
+                break;
+            }
+            if(nums[mid]>nums[high]) low = mid+1;
+            else high = mid-1;
+        }
+        low = 0, high = index;
+        while(low<=high)
+        {
+            int mid=low+(high-low)/2;
+            if(nums[mid]==target) return mid;
+            else if(nums[mid]>target) high = mid-1;
+            else low = mid+1;
+        }
+        low = index+1, high = n-1;
+        while(low<=high)
+        {
+            int mid=low+(high-low)/2;
+            if(nums[mid]==target) return mid;
+            else if(nums[mid]>target) high = mid-1;
+            else low = mid+1;
+        }
+        return -1;
+    }
+};

From 4048706af6a6e19e629061a52b92ab82404295fc Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Mon, 5 Oct 2020 00:47:37 +0530
Subject: [PATCH 049/203] Delete LowerBound.cpp

---
 05-Searching/LowerBound.cpp | 27 ---------------------------
 1 file changed, 27 deletions(-)
 delete mode 100644 05-Searching/LowerBound.cpp

diff --git a/05-Searching/LowerBound.cpp b/05-Searching/LowerBound.cpp
deleted file mode 100644
index df49155..0000000
--- a/05-Searching/LowerBound.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
-Lower Bound
-
-*/
-#include<bits/stdc++.h>
-using namespace std;
-
-int main()
-{
-    int arr[]={2,6,8,12,15,29,35,51,51,167,232,303,489,500};
-    int target=51;
-
-    int l=0,r=14;
-    while(l<r)
-    {
-        int mid=l+(r-l)/2;
-        if(target<=arr[mid])
-        {
-           r=mid;
-        }
-        else{
-            l=mid+1;
-        }
-    }
-    cout<<l;
-
-}
\ No newline at end of file

From 93586775c645f3187365bc4b7af495d64487255c Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Mon, 5 Oct 2020 00:47:48 +0530
Subject: [PATCH 050/203] Delete Interpolation_Search.cpp

---
 05-Searching/Interpolation_Search.cpp | 103 --------------------------
 1 file changed, 103 deletions(-)
 delete mode 100644 05-Searching/Interpolation_Search.cpp

diff --git a/05-Searching/Interpolation_Search.cpp b/05-Searching/Interpolation_Search.cpp
deleted file mode 100644
index 34329b5..0000000
--- a/05-Searching/Interpolation_Search.cpp
+++ /dev/null
@@ -1,103 +0,0 @@
-//INTERPOLATION SEARCH
-#include<bits/stdc++.h> //Importing library (This is the special type of library which will include all basic libraries)
-
-using namespace std;
-
-// If the searching element is present it will return its index, else it will return -1. 
-
-int interpolationSearch(int arr[], int n, int x) {
-  int low = 0, high = (n - 1); //Assigning lower index as 0 and higher index as n-1
-
-  while (low <= high && x >= arr[low] && x <= arr[high]) {
-    if (low == high) {
-      if (arr[low] == x) return low;
-      return -1;
-    }
-    // Probing the position with keeping uniform distribution in mind. 
-    int pos = low + (((double)(high - low) /
-      (arr[high] - arr[low])) * (x - arr[low]));
-
-    // Condition of element to be found 
-    if (arr[pos] == x)
-      return pos;
-
-    // If x is larger, x is in upper part 
-    if (arr[pos] < x)
-      low = pos + 1;
-
-    // If x is smaller, x is in the lower part 
-    else
-      high = pos - 1;
-  }
-  return -1;
-}
-
-int main() //Starting our main function 
-{
-
-  int num, x, loc;
-  std::cout << "Enter size of an array: ";
-  std::cin >> num;
-  int arr[num]; //Creating array of the size num
-  std::cout << "Enter elements: " << std::endl;
-
-  for (int i = 0; i < num; i++) //Enter the elements in the array
-  {
-    std::cin >> arr[i];
-  }
-
-  //Sorting our array
-
-  int n = sizeof(arr) / sizeof(arr[0]);
-  sort(arr, arr + n);
-
-  cout << "\nArray after sorting using "
-  "default sort is : \n" << std::endl;
-  for (int i = 0; i < n; ++i) {
-    cout << arr[i] << " ";
-
-  }
-  cout << std::endl;
-
-  //Entering the searching element
-  std::cout << "Enter element to be searched: " << std::endl;
-  cin >> x; //Element to be searched 
-  int index = interpolationSearch(arr, n, x);
-  //If element was found 
-  if (index != -1)
-    cout << "Element found at index " << index; //Returning the index pf the element
-  else
-    cout << "Element not found."; //Returning -1 as element has not found 
-
-  return 0;
-}
-
-/*
-SAMPLE INPUT:
-
-5 
-1
-7
-4
-9
-2 
-4
-
-SAMPLE OUTPUT:
-Enter size of an array: Enter elements: 
-
-Array after sorting using default sort is : 
-
-1 2 4 7 9 
-Enter element to be searched: 
-4
-Element found at index 2
-
-Time Complexity of Interpolation Search Algorithm
-Average Case: O (log log n) 
-Worst Case: O(N)
-
-Space Complexity of Interpolation Search Algorithm is O(1)
-*/
-
-

From f6f90711a95a0f8d2671d2267d48b64b3d2d7c4a Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Mon, 5 Oct 2020 00:47:59 +0530
Subject: [PATCH 051/203] Delete UpperBound.cpp

---
 05-Searching/UpperBound.cpp | 28 ----------------------------
 1 file changed, 28 deletions(-)
 delete mode 100644 05-Searching/UpperBound.cpp

diff --git a/05-Searching/UpperBound.cpp b/05-Searching/UpperBound.cpp
deleted file mode 100644
index 93e0317..0000000
--- a/05-Searching/UpperBound.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
-Upper Bound
-
-*/
-#include<bits/stdc++.h>
-using namespace std;
-
-int main()
-{
-    int arr[]={2,6,8,12,15,29,35,51,51,167,232,303,489,500};
-    int target=51;
-
-    int l=0,r=14;
-    while(l<r)
-    {
-        int mid=l+(r-l)/2;
-        if(target>=arr[mid])
-        {
-          
-           l=mid+1;
-        }
-        else{
-             r=mid;
-        }
-    }
-    cout<<l;
-
-}
\ No newline at end of file

From b651d5998737c6b4dca34d770eea6161bc6181b8 Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Mon, 5 Oct 2020 00:48:21 +0530
Subject: [PATCH 052/203] Delete MatrixRotation.cpp

---
 03-Arrays/MatrixRotation.cpp | 80 ------------------------------------
 1 file changed, 80 deletions(-)
 delete mode 100644 03-Arrays/MatrixRotation.cpp

diff --git a/03-Arrays/MatrixRotation.cpp b/03-Arrays/MatrixRotation.cpp
deleted file mode 100644
index b48e65f..0000000
--- a/03-Arrays/MatrixRotation.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-#include<iostream>
-using namespace std;
-
-//Function to input the matrix from the user
-void inputMatrix(int matrix[][10], int row, int column)
-{
-   printf("\nEnter elements: \n");
-   for (int i = 0; i < row; ++i)
-      for (int j = 0; j < column; ++j)
-      {
-         printf("Enter a[%d][%d]: ", i + 1, j + 1);
-         cin>>matrix[i][j];
-      }
-}
-
-//Function to print a given matrix
-void printMatrix(int matrix[][10], int row, int column)
-{
-   for (int i = 0; i < row; ++i)
-        for (int j = 0; j < column; ++j)
-        {
-            printf("%d  ", matrix[i][j]);
-            if (j == column - 1)
-            printf("\n");
-        }
-}
-
-//Function to swap two integers
-void swap(int *a, int *b) 
-{ 
-    int t = *a; 
-    *a = *b; 
-    *b = t; 
-}
-
-//Function to find the transpose of a matrix
-void findTranspose(int matrix[][10], int transpose[][10],int row, int column)
-{
-    for(int i=0;i<row;i++)
-        for(int j=0;j<column;j++)
-            transpose[j][i] = matrix[i][j];
-}
-
-//Function to find the clockwise rotated matrix
-void findClockwiseMatrix(int matrix[][10], int clockwise[][10],int row, int column)
-{
-    findTranspose(matrix,clockwise,row,column);
-    for(int i=0;i<column;i++)
-        for(int j=0;j<row/2;j++)
-            swap(&clockwise[i][j], &clockwise[i][row-j-1]);            
-}
-
-//Function to find the antilcokwise rotated matrix
-void findAntiClockwiseMatrix(int matrix[][10], int aclockwise[][10],int row, int column)
-{
-    findTranspose(matrix,aclockwise,row,column);
-    for(int i=0;i<column/2;i++)
-        for(int j=0;j<row;j++)
-            swap(&aclockwise[i][j], &aclockwise[column-i-1][j]);              
-}
-
-int main()
-{
-    int matrix[10][10],clockwise[10][10],aclockwise[10][10],row,column;
-
-    printf("\nEnter the row and column values: ");
-    cin>>row>>column;
-
-    inputMatrix(matrix,row,column); 
-    //Function to find out the clockwise rotated matrix
-    findClockwiseMatrix(matrix,clockwise,row,column); 
-    //Function to find out the anticlockwise rotated matrix
-    findAntiClockwiseMatrix(matrix,aclockwise,row,column);  
-
-    printf("\nMatrix rotated by 90 degree clockwise: \n");
-    printMatrix(clockwise,column,row);
-
-    printf("\nMatrix rotated by 90 degree anticlockwise: \n");
-    printMatrix(aclockwise,column,row);
-}
\ No newline at end of file

From 0db3b35e45de6c6ebd564895d3a717e90d3ebc7f Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Mon, 5 Oct 2020 00:48:48 +0530
Subject: [PATCH 053/203] Delete InversionCount.cpp

---
 04-Sorting/InversionCount.cpp | 46 -----------------------------------
 1 file changed, 46 deletions(-)
 delete mode 100644 04-Sorting/InversionCount.cpp

diff --git a/04-Sorting/InversionCount.cpp b/04-Sorting/InversionCount.cpp
deleted file mode 100644
index 0c37ca0..0000000
--- a/04-Sorting/InversionCount.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-#include<iostream>
-using namespace std;
-int merge(int *a, int s, int e){
-	int mid= (s+e)/2;
-	int i=s;
-	int j=mid+1;
-	int k=s;
-	int temp[1000];
-	int cnt=0;
-
-	while(i<=mid and j<=e){
-		if(a[i]<=a[j]){
-			temp[k++]=a[i++];
-		}
-		else{
-			temp[k++]=a[i++];
-			cnt+= mid-i+1;
-		}
-	}
-	while(i<=mid){
-		temp[k++]= a[i++];
-	}
-	while(j<=e){
-		temp[k++]=a[i++];
-	}
-	for(int i=s;i<=e;i++){
-		a[i]=temp[i];
-}
-	return cnt;
-}
-int inversion_count(int *a, int s, int e){
-	if(s>=e){
-		return 0;
-	}
-	int mid= (s+e)/2;
-	int x= inversion_count(a,s,mid);
-	int y= inversion_count(a,mid+1,e);
-	int z= merge(a,s,e);
-	return x+y+z;
-}
-int main()
-{
-	int a[]= {1,3,4,6,8,0};
-	int n= sizeof(a)/sizeof(int);
-	cout<<inversion_count(a,0,n-1)<<endl;
-}
\ No newline at end of file

From 143280602b69738ee66396cab36c3ec2a71a3399 Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Mon, 5 Oct 2020 00:48:58 +0530
Subject: [PATCH 054/203] Delete countingsort.cpp

---
 04-Sorting/countingsort.cpp | 28 ----------------------------
 1 file changed, 28 deletions(-)
 delete mode 100644 04-Sorting/countingsort.cpp

diff --git a/04-Sorting/countingsort.cpp b/04-Sorting/countingsort.cpp
deleted file mode 100644
index 3194eec..0000000
--- a/04-Sorting/countingsort.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-#include<iostream>
-using namespace std;
-void countingsort(int *a, int n){
-	int largest= -1;
-	for(int i=0;i<n;i++){
-		largest= max(largest,a[i]);
-	}
-	int *freq= new int[largest]{0};
-	for(int i=0;i<n;i++){
-		freq[a[i]]++;
-	}
-	int j=0;
-	for(int i=0;i<n;i++){
-		a[j]=i;
-		freq[i]--;
-		j++;
-	}
-}	
-
-int  main()
-{
-	int a[]= {2,3,5,12,19,6,8};
-	int n= sizeof(a)/sizeof(int);
-	countingsort(a,n);
-	for(int i=0;i<n;i++){
-		cout<<a[i]<<" ";
-	}
-}

From db71b69ba22bcc873c80c6eda3ed66f9f8ab9b23 Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Mon, 5 Oct 2020 00:49:09 +0530
Subject: [PATCH 055/203] Delete dnfsorting.cpp

---
 04-Sorting/dnfsorting.cpp | 32 --------------------------------
 1 file changed, 32 deletions(-)
 delete mode 100644 04-Sorting/dnfsorting.cpp

diff --git a/04-Sorting/dnfsorting.cpp b/04-Sorting/dnfsorting.cpp
deleted file mode 100644
index a0ad30c..0000000
--- a/04-Sorting/dnfsorting.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-#include<iostream>
-using namespace std;
-int dnfsort(int a[], int n){
-	int low= 0;
-	int high= n-1;
-	int mid=0;
-	while(mid<=high){
-		if(a[mid]==0){
-			swap(a[mid],a[low]);
-			mid++;
-			low++;
-		}
-		if(a[mid]==1){
-			mid++;
-		}
-		if(a[mid]==2){
-			swap(a[mid],a[high]);
-			high--;
-		}
-	}
-	return 0;
-}
-
-int main()
-{
-	int a[]= {1,0,0,2,1,1,0,0,1};
-	int n= sizeof(a)/sizeof(int);
-	dnfsort(a,n);
-    for(int i=0;i<n;i++){
-    	cout<<a[i]<<" ";
-    }
-}

From a89355d0d356b61223e7c6ea211cfcacf6f7dde0 Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Mon, 5 Oct 2020 00:49:19 +0530
Subject: [PATCH 056/203] Delete mergeSort.cpp

---
 04-Sorting/mergeSort.cpp | 54 ----------------------------------------
 1 file changed, 54 deletions(-)
 delete mode 100644 04-Sorting/mergeSort.cpp

diff --git a/04-Sorting/mergeSort.cpp b/04-Sorting/mergeSort.cpp
deleted file mode 100644
index c8902ee..0000000
--- a/04-Sorting/mergeSort.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-#include<iostream>
-using namespace std;
-void merge(int *a, int s, int e){
-	int temp[100];
-	int mid=(s+e)/2;
-	int i=s;
-	int j=mid;
-	int k= s;
-	
-	while(i<=mid && j<=e){
-		if(a[i]<a[j]){
-			temp[k++]=a[i++];
-		}
-		else {
-			temp[k++]=a[j++];		}
-		}
-		while(i<=mid){
-			temp[k++]=a[i++];
-		}
-		while(j<=e){
-			temp[k++]=a[j++];
-		}
-		for(int i=s;i<=e;i++){
-			a[i]=temp[i];
-		}
-		}
-
-
-void mergeSort(int a[], int s, int e){
-	//Base Case
-	if(s>=e){
-		return;
-	}
-	//Rec Case
-	//1. Devide 
-    int mid= (s+e)/2;
-    mergeSort(a,s,mid);
-    mergeSort(a,mid+1,e);
-    merge(a,s,e);
-
-}
-
-int main()
-{
-	int n;cin>>n;
-	int a[1000];
-	for(int i=0;i<n;i++){
-		cin>>a[i];
-	}
-	mergeSort(a,0,n-1);
-	for(int i=0;i<n;i++){
-		cout<<a[i]<<" ";
-	}
-}
\ No newline at end of file

From 526fe2fae676ec08d979ad262cde97b1f9f136ea Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Mon, 5 Oct 2020 00:52:14 +0530
Subject: [PATCH 057/203] Delete binary_to_DLL.cpp

---
 18-Binary Tree/binary_to_DLL.cpp | 42 --------------------------------
 1 file changed, 42 deletions(-)
 delete mode 100644 18-Binary Tree/binary_to_DLL.cpp

diff --git a/18-Binary Tree/binary_to_DLL.cpp b/18-Binary Tree/binary_to_DLL.cpp
deleted file mode 100644
index e630d5e..0000000
--- a/18-Binary Tree/binary_to_DLL.cpp	
+++ /dev/null
@@ -1,42 +0,0 @@
-
-// } Driver Code Ends
-
-
-/* Structure for tree and linked list
-
-struct Node
-{
-    int data;
-    struct Node* left;
-    struct Node* right;
-    
-    Node(int x){
-        data = x;
-        left = right = NULL;
-    }
-};
- */
-
-// This function should convert a given Binary tree to Doubly
-// Linked List
-
-void bToDLL(Node *root, Node **head)
-{
-    if(root==NULL)
-        return;
-    static Node* prev=NULL;
-    bToDLL(root->left,head);
-    if(*head==NULL)
-    {
-        prev=NULL;
-        *head=root;
-    }
-    else
-    {
-        root->left=prev;
-        prev->right=root;
-    }
-    prev=root;
-    bToDLL(root->right,head);
-}
-

From a299c0c0dbc0b732528bccd7a01ba3bdd0cde89b Mon Sep 17 00:00:00 2001
From: codewithdev <dev.18715@knit.ac.in>
Date: Mon, 5 Oct 2020 01:07:16 +0530
Subject: [PATCH 058/203] Updated

---
 C-plus-plus-Algorithms | 1 -
 1 file changed, 1 deletion(-)
 delete mode 160000 C-plus-plus-Algorithms

diff --git a/C-plus-plus-Algorithms b/C-plus-plus-Algorithms
deleted file mode 160000
index 018d92c..0000000
--- a/C-plus-plus-Algorithms
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 018d92c54b9f386292f5b1bd3c940d4ccb72d427

From d794e91e985b944b306bfed4aa8c8754e7e49d60 Mon Sep 17 00:00:00 2001
From: codewithdev <dev.18715@knit.ac.in>
Date: Mon, 5 Oct 2020 01:12:49 +0530
Subject: [PATCH 059/203] Updated

---
 04-Sorting/{radix_sort(souvick roy) => }/Radix_sort.cpp | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename 04-Sorting/{radix_sort(souvick roy) => }/Radix_sort.cpp (100%)

diff --git a/04-Sorting/radix_sort(souvick roy)/Radix_sort.cpp b/04-Sorting/Radix_sort.cpp
similarity index 100%
rename from 04-Sorting/radix_sort(souvick roy)/Radix_sort.cpp
rename to 04-Sorting/Radix_sort.cpp

From 5627b24a289e4bcfedc8411129491851189e6082 Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Mon, 5 Oct 2020 01:28:14 +0530
Subject: [PATCH 060/203] Update .travis.yml

---
 .travis.yml | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/.travis.yml b/.travis.yml
index f069c3d..6cf1fb7 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,3 +1,17 @@
+branches:
+  only:
+  - master
+  - stable
+
 language: cpp
+
 compiler:
+  - clang
   - gcc
+  -clang++
+  
+jobs:
+  fast_finish: true
+
+git:
+  submodules: false

From 8d74cf8f760d79b9094d231ef5847e444cc4bf18 Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Mon, 5 Oct 2020 01:39:05 +0530
Subject: [PATCH 061/203] Update .travis.yml

---
 .travis.yml | 30 +++++++++++++++++++++++++-----
 1 file changed, 25 insertions(+), 5 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 6cf1fb7..dbe4c53 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,8 +1,3 @@
-branches:
-  only:
-  - master
-  - stable
-
 language: cpp
 
 compiler:
@@ -15,3 +10,28 @@ jobs:
 
 git:
   submodules: false
+  
+  name: C/C++ CI
+
+on:
+  push:
+    branches: [ master ]
+  pull_request:
+    branches: [ master ]
+
+jobs:
+  build:
+
+    runs-on: ubuntu-latest
+
+    steps:
+    - uses: actions/checkout@v2
+    - name: configure
+      run: ./configure
+    - name: make
+      run: make
+    - name: make check
+      run: make check
+    - name: make distcheck
+      run: make distcheck
+

From 82763a458ecb8f127c229a75265e989c00e5891e Mon Sep 17 00:00:00 2001
From: Shreyash Royzada <65035990+ShreyashRoyzada@users.noreply.github.com>
Date: Mon, 5 Oct 2020 03:09:56 +0530
Subject: [PATCH 062/203] Create #409 Longest Palindrome.cpp

---
 .../LeetCode/#409 Longest Palindrome.cpp      | 35 +++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#409 Longest Palindrome.cpp

diff --git a/ONLINE JUDGE/LeetCode/#409 Longest Palindrome.cpp b/ONLINE JUDGE/LeetCode/#409 Longest Palindrome.cpp
new file mode 100644
index 0000000..d2933ed
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#409 Longest Palindrome.cpp	
@@ -0,0 +1,35 @@
+class Solution {
+  public:
+    int longestPalindrome(string s) {
+     map<char,int> check;
+     int ans=0;
+     for(int i=0;i<s.size();i++)
+     {
+       check[s[i]]++;
+     }
+     vector<int> temp;
+     for(auto &x : check)
+     {
+       int val = x.second;
+      
+       if(val%2==0)
+       {
+         ans=ans+val;
+       }
+       else
+       {
+         temp.push_back(val);
+       }
+     }
+     if(temp.size()!=0)
+     {
+         ans = ans+*max_element(temp.begin(),temp.end());
+         temp.erase(max_element(temp.begin(),temp.end()));
+         for(int i=0;i<temp.size();i++)
+         {
+             ans = ans + temp[i] - 1;
+         }
+     }
+     return ans;
+     }
+};

From 1f8be40c4faa2c40caed53ca66635a4b00e762f9 Mon Sep 17 00:00:00 2001
From: Shreyash Royzada <65035990+ShreyashRoyzada@users.noreply.github.com>
Date: Mon, 5 Oct 2020 03:11:48 +0530
Subject: [PATCH 063/203] Create #54 Spiral Matrix.cpp

---
 ONLINE JUDGE/LeetCode/#54 Spiral Matrix.cpp | 46 +++++++++++++++++++++
 1 file changed, 46 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#54 Spiral Matrix.cpp

diff --git a/ONLINE JUDGE/LeetCode/#54 Spiral Matrix.cpp b/ONLINE JUDGE/LeetCode/#54 Spiral Matrix.cpp
new file mode 100644
index 0000000..3fa787a
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#54 Spiral Matrix.cpp	
@@ -0,0 +1,46 @@
+
+class Solution {
+  public:
+    vector<int> spiralOrder(vector<vector<int>>& matrix) {
+      vector<int> ans;
+      if(matrix.size()==0)
+      {
+          return ans;
+      }
+      int top = 0 , right = matrix[0].size()-1, bottom = matrix.size()-1, left = 0;
+      while(top<=bottom&&left<=right)
+      {
+        //top layer
+        for(int i=left;i<=right;i++)
+        {
+          ans.push_back(matrix[top][i]);
+        }
+        top++;
+        
+        //right layer
+        for(int i=top;i<=bottom;i++)
+        {
+          ans.push_back(matrix[i][right]);
+        }
+        right--;
+        if(top>bottom||left>right)
+        {
+            break;
+        }
+        //bottom layer
+        for(int i=right;i>=left;i--)
+        {
+          ans.push_back(matrix[bottom][i]);
+        }
+        bottom--;
+        
+        //left layer
+        for(int i=bottom;i>=top;i--)
+        {
+          ans.push_back(matrix[i][left]);
+        }
+        left++;
+      }
+    return ans;
+    }
+};

From c3a88766b87f84493d40f349fece410a39193102 Mon Sep 17 00:00:00 2001
From: Priyanshi Sharma <priyanshi417@gmail.com>
Date: Mon, 5 Oct 2020 03:14:58 +0530
Subject: [PATCH 064/203] Create WATSCORE_DEC19B.cpp

---
 .../CodeChef Challenges/WATSCORE_DEC19B.cpp   | 29 +++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 ONLINE JUDGE/CodeChef Challenges/WATSCORE_DEC19B.cpp

diff --git a/ONLINE JUDGE/CodeChef Challenges/WATSCORE_DEC19B.cpp b/ONLINE JUDGE/CodeChef Challenges/WATSCORE_DEC19B.cpp
new file mode 100644
index 0000000..3628332
--- /dev/null
+++ b/ONLINE JUDGE/CodeChef Challenges/WATSCORE_DEC19B.cpp	
@@ -0,0 +1,29 @@
+#include <iostream>
+using namespace std;
+
+int main()
+{
+    int t,i , tc,n,s[8]={0,0,0,0,0,0,0,0},p[1000],sc[1000],sum;
+    cin>>tc;
+    for(t=0;t<tc;++t)
+    {
+        cin>>n;
+        for(i=0;i<n;++i)
+        {
+            cin>>p[i]>>sc[i];
+            if((sc[i]>s[p[i]-1])&&p[i]<9&&p[i]>0)
+            {
+                s[p[i]-1]=sc[i];
+            }
+        }
+        sum=0;
+        for(i=0;i<8;++i)
+        {
+            sum+=s[i];
+            s[i]=0;
+        }
+        cout<<sum<<endl;
+        
+    }
+    return 0;
+}

From 2d6e0a26b0182ddda92300894d8ff6a40fa849a0 Mon Sep 17 00:00:00 2001
From: Priyanshi Sharma <priyanshi417@gmail.com>
Date: Mon, 5 Oct 2020 03:16:03 +0530
Subject: [PATCH 065/203] Create PMLU_DEC19B.cpp

---
 .../CodeChef Challenges/PMLU_DEC19B.cpp       | 31 +++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100644 ONLINE JUDGE/CodeChef Challenges/PMLU_DEC19B.cpp

diff --git a/ONLINE JUDGE/CodeChef Challenges/PMLU_DEC19B.cpp b/ONLINE JUDGE/CodeChef Challenges/PMLU_DEC19B.cpp
new file mode 100644
index 0000000..fb13dbc
--- /dev/null
+++ b/ONLINE JUDGE/CodeChef Challenges/PMLU_DEC19B.cpp	
@@ -0,0 +1,31 @@
+#include <iostream>
+using namespace std;
+
+int main()
+{
+    int t,i,j , tc,n, arr[40000],ctr=0;
+    cin>>tc;
+    for(t=0;t<tc;++t)
+    {
+        cin>>n;
+        for(i=0;i<n;++i)
+        {
+            cin>>arr[i];
+        }
+        for(i=0;i<n;++i)
+        {
+            for(j=i+1;j<n;++j)
+            {
+                if((arr[i]+arr[j])==(arr[i]*arr[j]))
+                {
+                    ctr++;
+                    //cout<<endl<<i<<"\t"<<j<<"\t"<<ctr<<endl;
+                }
+            }
+        }
+        cout<<ctr<<endl;
+        ctr=0;
+        
+    }
+    return 0;
+}

From 024ee9652ff10a85762b6d2f4d2feba8efc63cd6 Mon Sep 17 00:00:00 2001
From: Shreyash Royzada <65035990+ShreyashRoyzada@users.noreply.github.com>
Date: Mon, 5 Oct 2020 03:16:23 +0530
Subject: [PATCH 066/203] Create #48-Rotate Image.cpp

---
 ONLINE JUDGE/LeetCode/#48-Rotate Image.cpp | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#48-Rotate Image.cpp

diff --git a/ONLINE JUDGE/LeetCode/#48-Rotate Image.cpp b/ONLINE JUDGE/LeetCode/#48-Rotate Image.cpp
new file mode 100644
index 0000000..0cf6783
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#48-Rotate Image.cpp	
@@ -0,0 +1,21 @@
+class Solution {
+public:
+    void rotate(vector<vector<int>>& matrix) {
+        int n=matrix.size()/2,i=0,sz=matrix.size()-1;
+      for(int i=0;i<n;i++)
+      {
+        for(int j=i;j<sz-i;j++)
+        {
+          int temp1 = matrix[i][j];
+          int temp2 = matrix[j][sz-i];
+          int temp3 = matrix[sz-i][sz-j];
+          int temp4 = matrix[sz-j][i];
+          matrix[i][j] = temp4;
+          matrix[j][sz-i] = temp1;
+          matrix[sz-i][sz-j] = temp2;
+          matrix[sz-j][i] = temp3;
+        }
+      }
+    
+    }
+};

From 83ac594736345920ce0b374e48900312799eab28 Mon Sep 17 00:00:00 2001
From: Priyanshi Sharma <priyanshi417@gmail.com>
Date: Mon, 5 Oct 2020 03:18:26 +0530
Subject: [PATCH 067/203] Create LECANDY.cpp

---
 ONLINE JUDGE/CodeChef Challenges/LECANDY.cpp | 30 ++++++++++++++++++++
 1 file changed, 30 insertions(+)
 create mode 100644 ONLINE JUDGE/CodeChef Challenges/LECANDY.cpp

diff --git a/ONLINE JUDGE/CodeChef Challenges/LECANDY.cpp b/ONLINE JUDGE/CodeChef Challenges/LECANDY.cpp
new file mode 100644
index 0000000..2be6b0a
--- /dev/null
+++ b/ONLINE JUDGE/CodeChef Challenges/LECANDY.cpp	
@@ -0,0 +1,30 @@
+#include <iostream>
+using namespace std;
+
+int main() {
+	int T;
+	cin>>T;
+	int i;
+	for(i=0;i<T;++i)
+	{
+	    int N ;
+	    long C;
+	    cin>>N>>C;
+	    long sum=0;
+	    int j,k;
+	    for(j=0;j<N;++j)
+	    {
+	        int k;
+	        cin>>k;
+	        sum+=k;
+	        //cout<<endl<<k<<' '<<sum<<endl;
+	    }
+	    if(sum<=C)
+	    {
+	        cout<<"Yes"<<endl;
+	    }
+	    else
+	    cout<<"No"<<endl;
+	}
+	return 0;
+}

From c4cd349d48434f4911d9c21a029e272359367c1a Mon Sep 17 00:00:00 2001
From: Priyanshi Sharma <priyanshi417@gmail.com>
Date: Mon, 5 Oct 2020 03:19:41 +0530
Subject: [PATCH 068/203] Create FFL_LTIME83B.cpp

---
 .../CodeChef Challenges/FFL_LTIME83B.cpp      | 35 +++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 ONLINE JUDGE/CodeChef Challenges/FFL_LTIME83B.cpp

diff --git a/ONLINE JUDGE/CodeChef Challenges/FFL_LTIME83B.cpp b/ONLINE JUDGE/CodeChef Challenges/FFL_LTIME83B.cpp
new file mode 100644
index 0000000..0ee5d67
--- /dev/null
+++ b/ONLINE JUDGE/CodeChef Challenges/FFL_LTIME83B.cpp	
@@ -0,0 +1,35 @@
+#include <iostream>
+using namespace std;
+
+int main() {
+	int T,N,S,minz,mino;
+	cin>>T;
+	
+	while(T--)
+	{
+	    minz=100;
+	    mino=100;
+	    cin>>N>>S;
+	    int A1[N],A2[N];
+	    for(int i=0;i<N;++i)
+	        cin>>A1[i];
+	   for(int i=0;i<N;++i)
+	        cin>>A2[i];
+	   for(int i=0;i<N;i++)
+	   {
+	       if(A2[i]==0)
+	       {
+	           minz=minz<A1[i]?minz:A1[i];
+	       }
+	       if(A2[i]==1)
+	       {
+	           mino=mino<A1[i]?mino:A1[i];
+	       }
+	   }
+	   if((S+minz+mino)<=100)
+	        cout<<"yes"<<endl;
+	   else
+	    cout<<"no"<<endl;
+	}
+	return 0;
+}

From 1dde41bb690624eb10d54c06485508f54928fe3a Mon Sep 17 00:00:00 2001
From: Shreyash Royzada <65035990+ShreyashRoyzada@users.noreply.github.com>
Date: Mon, 5 Oct 2020 03:21:52 +0530
Subject: [PATCH 069/203] Create #15-3Sum.cpp

---
 ONLINE JUDGE/LeetCode/#15-3Sum.cpp | 49 ++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#15-3Sum.cpp

diff --git a/ONLINE JUDGE/LeetCode/#15-3Sum.cpp b/ONLINE JUDGE/LeetCode/#15-3Sum.cpp
new file mode 100644
index 0000000..6bf0be8
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#15-3Sum.cpp	
@@ -0,0 +1,49 @@
+class Solution {
+  public:
+    vector<vector<int>> threeSum(vector<int>& A) {
+        if(A.size()<3)
+        {
+            vector<vector<int>> emp;
+            return emp;
+        }
+      set<vector<int>> ans;
+      sort(A.begin(),A.end());
+      for(int i=0;i<A.size()-2;i++)
+      {
+        if(i==0||A[i]>A[i-1])
+        {
+        int left=i+1,right=A.size()-1;
+        
+        while(left<right)
+        {
+          if(A[left]+A[right]>(-A[i]))
+          {
+              right--;
+          }
+          else if(A[left]+A[right]<(-A[i]))
+          {
+              left++;
+          }
+          
+          if((right!=left)&&(A[left]+A[right]==(-A[i])))
+          {
+          vector<int> temp;
+          temp.push_back(A[i]);
+          temp.push_back(A[left]);
+          temp.push_back(A[right]);
+          ans.insert(temp);
+          left++;
+          right--;
+          }
+        }
+        
+        }
+      }
+      vector<vector<int>> ans1;
+      for(auto itr=ans.begin();itr!=ans.end();itr++)
+      {
+        ans1.push_back(*(itr));
+      }
+      return ans1;
+    }
+};

From 306c6254b18bca8fc5d6ea6eccdb1718998950b0 Mon Sep 17 00:00:00 2001
From: Shreyash Royzada <65035990+ShreyashRoyzada@users.noreply.github.com>
Date: Mon, 5 Oct 2020 03:23:40 +0530
Subject: [PATCH 070/203] Create #204-Count Primes.cpp

---
 ONLINE JUDGE/LeetCode/#204-Count Primes.cpp | 29 +++++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#204-Count Primes.cpp

diff --git a/ONLINE JUDGE/LeetCode/#204-Count Primes.cpp b/ONLINE JUDGE/LeetCode/#204-Count Primes.cpp
new file mode 100644
index 0000000..a11799a
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#204-Count Primes.cpp	
@@ -0,0 +1,29 @@
+class Solution {
+public:
+    int countPrimes(int n) {
+      int ans=0;
+      vector<long long int>arr;
+      for(int i=0;i<n;i++)
+      {
+        arr.push_back(0);
+      }
+      for(int i=2;i<n;i++)
+      {
+        if(arr[i]==0)
+        {
+          for(int j=2;i*j<n;j++)
+          {
+          arr[i*j]=1;
+          }
+        }
+      }
+      for(int i=2;i<n;i++)
+      {
+        if(arr[i]==0)
+        {
+          ans++;
+        }
+      }
+      return ans;
+    }
+};

From 6bc1983c50ada2c66fc52835f70eb05b623554bf Mon Sep 17 00:00:00 2001
From: Shreyash Royzada <65035990+ShreyashRoyzada@users.noreply.github.com>
Date: Mon, 5 Oct 2020 03:25:49 +0530
Subject: [PATCH 071/203] Delete #204-Count Primes.cpp

---
 ONLINE JUDGE/LeetCode/#204-Count Primes.cpp | 29 ---------------------
 1 file changed, 29 deletions(-)
 delete mode 100644 ONLINE JUDGE/LeetCode/#204-Count Primes.cpp

diff --git a/ONLINE JUDGE/LeetCode/#204-Count Primes.cpp b/ONLINE JUDGE/LeetCode/#204-Count Primes.cpp
deleted file mode 100644
index a11799a..0000000
--- a/ONLINE JUDGE/LeetCode/#204-Count Primes.cpp	
+++ /dev/null
@@ -1,29 +0,0 @@
-class Solution {
-public:
-    int countPrimes(int n) {
-      int ans=0;
-      vector<long long int>arr;
-      for(int i=0;i<n;i++)
-      {
-        arr.push_back(0);
-      }
-      for(int i=2;i<n;i++)
-      {
-        if(arr[i]==0)
-        {
-          for(int j=2;i*j<n;j++)
-          {
-          arr[i*j]=1;
-          }
-        }
-      }
-      for(int i=2;i<n;i++)
-      {
-        if(arr[i]==0)
-        {
-          ans++;
-        }
-      }
-      return ans;
-    }
-};

From 86e1517204578d7281198b130616373a4e48ec23 Mon Sep 17 00:00:00 2001
From: Shreyash Royzada <65035990+ShreyashRoyzada@users.noreply.github.com>
Date: Mon, 5 Oct 2020 03:29:03 +0530
Subject: [PATCH 072/203] Create #9-Palindrome Number.cpp

---
 .../LeetCode/#9-Palindrome Number.cpp         | 26 +++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#9-Palindrome Number.cpp

diff --git a/ONLINE JUDGE/LeetCode/#9-Palindrome Number.cpp b/ONLINE JUDGE/LeetCode/#9-Palindrome Number.cpp
new file mode 100644
index 0000000..768d1f1
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#9-Palindrome Number.cpp	
@@ -0,0 +1,26 @@
+class Solution {
+public:
+    
+    bool isPalindrome(int x) {
+        if(x==0)
+            return true;
+        if(x<0)
+        return false;
+      int size = log10(x)+1;
+      for(int i=0;i<size/2;i++)
+      {
+        int a=pow(10,size-1-(i*2)),b=10;
+        if(x/a!=x%b)
+        {
+          cout<<x<<" ";
+          return false;
+        }
+        else
+        {
+          x=x%a;
+          x=x/b;
+        }
+      }
+      return true;
+    }
+};

From 266340bea80564c7a09c076214eb547ed96b6057 Mon Sep 17 00:00:00 2001
From: Koulick Sadhu <ks2202@it.jgec.ac.in>
Date: Mon, 5 Oct 2020 03:32:27 +0530
Subject: [PATCH 073/203] Added LinkedlList Amazon_Microsoft Interview

Union and Intersection of LinkedList
---
 ...section_of_Linkedlist_Amazon_Microsoft.cpp | 146 ++++++++++++++++++
 1 file changed, 146 insertions(+)
 create mode 100644 Interview Problems/02- LinkedList/Union_and_Intersection_of_Linkedlist_Amazon_Microsoft.cpp

diff --git a/Interview Problems/02- LinkedList/Union_and_Intersection_of_Linkedlist_Amazon_Microsoft.cpp b/Interview Problems/02- LinkedList/Union_and_Intersection_of_Linkedlist_Amazon_Microsoft.cpp
new file mode 100644
index 0000000..2239017
--- /dev/null
+++ b/Interview Problems/02- LinkedList/Union_and_Intersection_of_Linkedlist_Amazon_Microsoft.cpp	
@@ -0,0 +1,146 @@
+// C/C++ program to find union 
+// and intersection of two unsorted 
+// linked lists 
+#include <stdbool.h> 
+#include <stdio.h> 
+#include <stdlib.h> 
+/* Link list node */
+struct Node { 
+	int data; 
+	struct Node* next; 
+}; 
+
+/* A utility function to insert a 
+node at the beginning ofa linked list*/
+void push(struct Node** head_ref, int new_data); 
+
+/* A utility function to check if 
+given data is present in a list */
+bool isPresent(struct Node* head, int data); 
+
+/* Function to get union of two 
+linked lists head1 and head2 */
+struct Node* getUnion( 
+	struct Node* head1, 
+	struct Node* head2) 
+{ 
+	struct Node* result = NULL; 
+	struct Node *t1 = head1, *t2 = head2; 
+
+	// Insert all elements of 
+	// list1 to the result list 
+	while (t1 != NULL) { 
+		push(&result, t1->data); 
+		t1 = t1->next; 
+	} 
+
+	// Insert those elements of list2 
+	// which are not present in result list 
+	while (t2 != NULL) { 
+		if (!isPresent(result, t2->data)) 
+			push(&result, t2->data); 
+		t2 = t2->next; 
+	} 
+
+	return result; 
+} 
+
+/* Function to get intersection of 
+two linked lists head1 and head2 */
+struct Node* getIntersection(struct Node* head1, 
+							struct Node* head2) 
+{ 
+	struct Node* result = NULL; 
+	struct Node* t1 = head1; 
+
+	// Traverse list1 and search each element of it in 
+	// list2. If the element is present in list 2, then 
+	// insert the element to result 
+	while (t1 != NULL) { 
+		if (isPresent(head2, t1->data)) 
+			push(&result, t1->data); 
+		t1 = t1->next; 
+	} 
+
+	return result; 
+} 
+
+/* A utility function to insert a 
+node at the beginning of a linked list*/
+void push(struct Node** head_ref, int new_data) 
+{ 
+	/* allocate node */
+	struct Node* new_node 
+		= (struct Node*)malloc( 
+			sizeof(struct Node)); 
+
+	/* put in the data */
+	new_node->data = new_data; 
+
+	/* link the old list off the new node */
+	new_node->next = (*head_ref); 
+
+	/* move the head to point to the new node */
+	(*head_ref) = new_node; 
+} 
+
+/* A utility function to print a linked list*/
+void printList(struct Node* node) 
+{ 
+	while (node != NULL) { 
+		printf("%d ", node->data); 
+		node = node->next; 
+	} 
+} 
+
+/* A utility function that returns true if data is 
+present in linked list else return false */
+bool isPresent(struct Node* head, int data) 
+{ 
+	struct Node* t = head; 
+	while (t != NULL) { 
+		if (t->data == data) 
+			return 1; 
+		t = t->next; 
+	} 
+	return 0; 
+} 
+
+/* Driver program to test above function*/
+int main() 
+{ 
+	/* Start with the empty list */
+	struct Node* head1 = NULL; 
+	struct Node* head2 = NULL; 
+	struct Node* intersecn = NULL; 
+	struct Node* unin = NULL; 
+
+	/*create a linked lits 10->15->5->20 */
+	push(&head1, 20); 
+	push(&head1, 4); 
+	push(&head1, 15); 
+	push(&head1, 10); 
+
+	/*create a linked lits 8->4->2->10 */
+	push(&head2, 10); 
+	push(&head2, 2); 
+	push(&head2, 4); 
+	push(&head2, 8); 
+
+	intersecn = getIntersection(head1, head2); 
+	unin = getUnion(head1, head2); 
+
+	printf("\n First list is \n"); 
+	printList(head1); 
+
+	printf("\n Second list is \n"); 
+	printList(head2); 
+
+	printf("\n Intersection list is \n"); 
+	printList(intersecn); 
+
+	printf("\n Union list is \n"); 
+	printList(unin); 
+
+	return 0; 
+} 

From bcd7ba1a2875b7816e3c570b0be9a57c7b697920 Mon Sep 17 00:00:00 2001
From: Nitin Gupta <nitingupta2906@gmail.com>
Date: Mon, 5 Oct 2020 03:46:01 +0530
Subject: [PATCH 074/203] Create #4Median-of-Two-Sorted-Arrays.cpp

Added Median of Two Sorted Arrays
---
 .../#4Median-of-Two-Sorted-Arrays.cpp         | 31 +++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#4Median-of-Two-Sorted-Arrays.cpp

diff --git a/ONLINE JUDGE/LeetCode/#4Median-of-Two-Sorted-Arrays.cpp b/ONLINE JUDGE/LeetCode/#4Median-of-Two-Sorted-Arrays.cpp
new file mode 100644
index 0000000..bdf5224
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#4Median-of-Two-Sorted-Arrays.cpp	
@@ -0,0 +1,31 @@
+class Solution {
+public:
+    double findMedianSortedArrays(vector<int>& nums1, vector<int>& nums2) {
+        vector<int>me;
+        int m=nums1.size();
+        int n=nums2.size();
+        int i=0,j=0;
+        while(i<m && j<n){
+            if(nums1[i]<nums2[j]){
+                me.push_back(nums1[i]);
+                i++;
+            }else{
+                me.push_back(nums2[j]);
+                j++;
+            }
+        }
+            while(i<m){
+                me.push_back(nums1[i]);
+                i++;
+            }
+            while(j<n){
+                me.push_back(nums2[j]);
+                j++;
+            }
+        
+        //for(int i=0;i<me.size();i++)cout<<me[i]<<"";
+        int s=me.size();
+        if(s%2!=0)  return me[s/2];
+        else        return (me[s / 2] + me[s/ 2 - 1]) / 2.0;
+    }
+};

From f7c27205ac61bb476df93869bad5cd9101050ba4 Mon Sep 17 00:00:00 2001
From: Nitin Gupta <nitingupta2906@gmail.com>
Date: Mon, 5 Oct 2020 03:48:34 +0530
Subject: [PATCH 075/203] Create #41-First-Missing-Positive.cpp

Added 41. First Missing Positive
---
 .../LeetCode/#41-First-Missing-Positive.cpp   | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#41-First-Missing-Positive.cpp

diff --git a/ONLINE JUDGE/LeetCode/#41-First-Missing-Positive.cpp b/ONLINE JUDGE/LeetCode/#41-First-Missing-Positive.cpp
new file mode 100644
index 0000000..59a642c
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#41-First-Missing-Positive.cpp	
@@ -0,0 +1,19 @@
+class Solution {
+public:
+    int firstMissingPositive(vector<int>& a) {
+        
+        int n=a.size();
+        set<int>temp;
+        
+        for(int i=0;i<n;i++){
+            if(a[i]>0) temp.insert(a[i]);
+        }
+        int ans=1;
+        for(auto i:temp){
+            if(ans!=i)  return ans;
+            else        ans++;
+        }
+        return ans;
+        
+    }
+};

From aebc16a5d4f187f6e315dc3decd0855d4997c7f3 Mon Sep 17 00:00:00 2001
From: Koulick Sadhu <ks2202@it.jgec.ac.in>
Date: Mon, 5 Oct 2020 03:54:28 +0530
Subject: [PATCH 076/203] Added Euler Totient Function

---
 09- Number Theory/Euler_Totient_Function.cpp | 37 ++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 09- Number Theory/Euler_Totient_Function.cpp

diff --git a/09- Number Theory/Euler_Totient_Function.cpp b/09- Number Theory/Euler_Totient_Function.cpp
new file mode 100644
index 0000000..6a982ff
--- /dev/null
+++ b/09- Number Theory/Euler_Totient_Function.cpp	
@@ -0,0 +1,37 @@
+// C program to calculate Euler's Totient Function
+#include <bits/stdc++.h>
+using namespace std;
+int phi(int n)
+{
+    int result = n; // Initialize result as n
+ 
+    // Consider all prime factors of n and subtract their
+    // multiples from result
+    for (int p = 2; p * p <= n; ++p) {
+         
+        // Check if p is a prime factor.
+        if (n % p == 0) {
+             
+            // If yes, then update n and result
+            while (n % p == 0)
+                n /= p;
+            result -= result / p;
+        }
+    }
+ 
+    // If n has a prime factor greater than sqrt(n)
+    // (There can be at-most one such prime factor)
+    if (n > 1)
+        result -= result / n;
+    return result;
+}
+ 
+// Driver program to test above function
+int main()
+{
+    int n;
+    for (n = 1; n <= 10; n++){
+        cout<<"Phi"<<"("<<n<<")"<<" = "<<phi(n)<<endl;
+    }
+    return 0;
+}

From 28246c5c164915a62bfaa3298fd5c6df309a76a7 Mon Sep 17 00:00:00 2001
From: Koulick Sadhu <ks2202@it.jgec.ac.in>
Date: Mon, 5 Oct 2020 03:56:47 +0530
Subject: [PATCH 077/203] Delete Euler_Totient_Function.cpp

---
 09- Number Theory/Euler_Totient_Function.cpp | 37 --------------------
 1 file changed, 37 deletions(-)
 delete mode 100644 09- Number Theory/Euler_Totient_Function.cpp

diff --git a/09- Number Theory/Euler_Totient_Function.cpp b/09- Number Theory/Euler_Totient_Function.cpp
deleted file mode 100644
index 6a982ff..0000000
--- a/09- Number Theory/Euler_Totient_Function.cpp	
+++ /dev/null
@@ -1,37 +0,0 @@
-// C program to calculate Euler's Totient Function
-#include <bits/stdc++.h>
-using namespace std;
-int phi(int n)
-{
-    int result = n; // Initialize result as n
- 
-    // Consider all prime factors of n and subtract their
-    // multiples from result
-    for (int p = 2; p * p <= n; ++p) {
-         
-        // Check if p is a prime factor.
-        if (n % p == 0) {
-             
-            // If yes, then update n and result
-            while (n % p == 0)
-                n /= p;
-            result -= result / p;
-        }
-    }
- 
-    // If n has a prime factor greater than sqrt(n)
-    // (There can be at-most one such prime factor)
-    if (n > 1)
-        result -= result / n;
-    return result;
-}
- 
-// Driver program to test above function
-int main()
-{
-    int n;
-    for (n = 1; n <= 10; n++){
-        cout<<"Phi"<<"("<<n<<")"<<" = "<<phi(n)<<endl;
-    }
-    return 0;
-}

From a7cd88fb18847d1e229b0b684e45db68cb8e9e47 Mon Sep 17 00:00:00 2001
From: Koulick Sadhu <ks2202@it.jgec.ac.in>
Date: Mon, 5 Oct 2020 03:57:50 +0530
Subject: [PATCH 078/203] Added Euler Totient Function

---
 09- Number Theory/Euler_Totient_Function.cpp | 37 ++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 09- Number Theory/Euler_Totient_Function.cpp

diff --git a/09- Number Theory/Euler_Totient_Function.cpp b/09- Number Theory/Euler_Totient_Function.cpp
new file mode 100644
index 0000000..2422589
--- /dev/null
+++ b/09- Number Theory/Euler_Totient_Function.cpp	
@@ -0,0 +1,37 @@
+// C++ program to calculate Euler's Totient Function
+#include <bits/stdc++.h>
+using namespace std;
+int phi(int n)
+{
+    int result = n; // Initialize result as n
+ 
+    // Consider all prime factors of n and subtract their
+    // multiples from result
+    for (int p = 2; p * p <= n; ++p) {
+         
+        // Check if p is a prime factor.
+        if (n % p == 0) {
+             
+            // If yes, then update n and result
+            while (n % p == 0)
+                n /= p;
+            result -= result / p;
+        }
+    }
+ 
+    // If n has a prime factor greater than sqrt(n)
+    // (There can be at-most one such prime factor)
+    if (n > 1)
+        result -= result / n;
+    return result;
+}
+ 
+// Driver program to test above function
+int main()
+{
+    int n;
+    for (n = 1; n <= 10; n++){
+        cout<<"Phi"<<"("<<n<<")"<<" = "<<phi(n)<<endl;
+    }
+    return 0;
+}

From 58827005efdb85165b5cc3e3e133c2e995776210 Mon Sep 17 00:00:00 2001
From: Mohit saha <52305250+mohitsaha@users.noreply.github.com>
Date: Mon, 5 Oct 2020 07:21:12 +0530
Subject: [PATCH 079/203] added world ladder problem as per #13

---
 ONLINE JUDGE/LeetCode/#127-Word-Ladder.cpp | 38 ++++++++++++++++++++++
 1 file changed, 38 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#127-Word-Ladder.cpp

diff --git a/ONLINE JUDGE/LeetCode/#127-Word-Ladder.cpp b/ONLINE JUDGE/LeetCode/#127-Word-Ladder.cpp
new file mode 100644
index 0000000..ab08f8d
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#127-Word-Ladder.cpp	
@@ -0,0 +1,38 @@
+class Solution {
+public:
+	int ladderLength(string beginWord, string endWord, vector<string>& wordList) {
+		unordered_set<string> s1;
+		unordered_set<string> s2;
+		unordered_set<string> dict(wordList.begin(),wordList.end());
+		if(!dict.count(endWord)) return 0;
+		int len=beginWord.size();
+		int ans=0;
+		s1.insert(beginWord);
+		s2.insert(endWord);
+		while(!s1.empty() && !s2.empty()){
+			ans++;
+			if(s1.size()>s2.size()){
+				swap(s1,s2);
+			}
+			unordered_set<string> cur;
+			for(string w:s1){
+				for(int i=0;i<len;i++){
+					char temp=w[i];
+					for(char x='a';x<='z';x++){
+						w[i]=x;
+						if(s2.count(w)){
+							return ans+1;
+						}
+						if(!dict.count(w))continue;
+						dict.erase(w);
+						cur.insert(w);
+					}
+					w[i]=temp;
+
+				}
+			}
+	s1=cur;
+		}
+return 0;
+	}
+};

From 92a7a2fbfee2632bc1ce9e0511a5b52861752f85 Mon Sep 17 00:00:00 2001
From: nyamako <43832368+nyamako@users.noreply.github.com>
Date: Sun, 4 Oct 2020 19:08:13 -0700
Subject: [PATCH 080/203] add solution to LeetCode #12

---
 .../LeetCode/#12-Integer_to_Roman.cpp         | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#12-Integer_to_Roman.cpp

diff --git a/ONLINE JUDGE/LeetCode/#12-Integer_to_Roman.cpp b/ONLINE JUDGE/LeetCode/#12-Integer_to_Roman.cpp
new file mode 100644
index 0000000..a33ec45
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#12-Integer_to_Roman.cpp	
@@ -0,0 +1,19 @@
+class Solution {
+public:
+    string intToRoman(int num) {
+        string roman[13] = {"M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"};
+        int decimal[13] = {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1};
+        string result = "";
+        int i = 0;
+        while(num > 0) {
+            if(num >= decimal[i]) {
+                result += roman[i];
+                num -= decimal[i];
+            }
+            else {
+                i++;
+            }
+        }
+        return result;
+    }
+};

From b89ff2a102cde905a9c44df4ae12cd7e46f8d327 Mon Sep 17 00:00:00 2001
From: sahiljethani <42886444+sahiljethani@users.noreply.github.com>
Date: Mon, 5 Oct 2020 11:01:38 +0530
Subject: [PATCH 081/203] Added Greedy Algorithm For Egyptian Fraction

---
 23- Greedy Algorithms/EgyptianFraction.cpp | 47 ++++++++++++++++++++++
 1 file changed, 47 insertions(+)
 create mode 100644 23- Greedy Algorithms/EgyptianFraction.cpp

diff --git a/23- Greedy Algorithms/EgyptianFraction.cpp b/23- Greedy Algorithms/EgyptianFraction.cpp
new file mode 100644
index 0000000..78f662a
--- /dev/null
+++ b/23- Greedy Algorithms/EgyptianFraction.cpp	
@@ -0,0 +1,47 @@
+
+// Program to print a fraction in Egyptian Form using Greedy Algorithm
+/*
+ Example:Egyptian Fraction Representation of 6/14 is 1/3 + 1/11 + 1/231
+         Egyptian Fraction Representation of 12/13 is 1/2 + 1/3 + 1/12 + 1/156
+ */
+#include <iostream>
+using namespace std;
+  
+void printEgyptian(int num, int dnum)
+{
+    if (dnum == 0 || num == 0)
+        return;
+  
+    if (dnum%num == 0)
+    {
+        cout << "1/" << dnum/num;
+        return;
+    }
+
+    if (num%dnum == 0)
+    {
+        cout << num/dnum;
+        return;
+    }
+
+    if (num > dnum)
+    {
+        cout << num/dnum << " + ";
+        printEgyptian(num%dnum, dnum);
+        return;
+    }
+  
+    int n = dnum/num + 1;
+    cout << "1/" << n << " + ";
+  
+    printEgyptian(num*n-dnum, dnum*n);
+ }
+  
+int main()
+{
+    int num = 12, dnum= 13;
+    cout << "Egyptian Fraction Representation of "
+         << num << "/" << dnum << " is\n ";
+    printEgyptian(num, dnum);
+    return 0;
+}

From 178f7330881eb95b633d4db3d933b455cbf448ae Mon Sep 17 00:00:00 2001
From: Aditya Parthasarathy <adityap301@gmail.com>
Date: Mon, 5 Oct 2020 11:06:42 +0530
Subject: [PATCH 082/203] Added erase() of vectors

---
 08-Vector/erase.cpp | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
 create mode 100644 08-Vector/erase.cpp

diff --git a/08-Vector/erase.cpp b/08-Vector/erase.cpp
new file mode 100644
index 0000000..8fc167c
--- /dev/null
+++ b/08-Vector/erase.cpp
@@ -0,0 +1,14 @@
+#include<iostream>
+#include<vector>
+using namespace std;
+int main()
+{
+	vector<int>v{1, 2, 3, 4, 5, 14};
+	vector<int>::iterator it;
+	// Delete last element
+	it = v.end()-1;
+	v.erase(it);
+	for (int x:v) {
+		cout<<x<< ",";
+	}
+}
\ No newline at end of file

From 2b0f412aea3c876e200aa37f19c795f8a536d67b Mon Sep 17 00:00:00 2001
From: Aditya Parthasarathy <adityap301@gmail.com>
Date: Mon, 5 Oct 2020 11:53:06 +0530
Subject: [PATCH 083/203] Added problem #771 - Jewels and Stones

I have added the solution class for the problem #771 -
'Jewels and Stones'. It has runtime: 0ms and
memory usage: 6.4MB
---
 ONLINE JUDGE/LeetCode/#771-Jewels_And_Stones.cpp | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#771-Jewels_And_Stones.cpp

diff --git a/ONLINE JUDGE/LeetCode/#771-Jewels_And_Stones.cpp b/ONLINE JUDGE/LeetCode/#771-Jewels_And_Stones.cpp
new file mode 100644
index 0000000..4072e44
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#771-Jewels_And_Stones.cpp	
@@ -0,0 +1,14 @@
+class Solution {
+public:
+    int numJewelsInStones(string J, string S) {
+        int res = 0;
+        unordered_set<char> J_set(J.begin(), J.end()); 
+        //Start iterator, end iterator is passed to the constructor to make the set
+        for(int i=0; i<S.size(); i++)
+        {
+            if(J_set.find(S[i]) != J_set.end())
+                res++;
+        }
+        return res;
+    }
+};
\ No newline at end of file

From 6526240edcd1338fdfd60d9900d4c7b14090d754 Mon Sep 17 00:00:00 2001
From: Aditya Parthasarathy <adityap301@gmail.com>
Date: Mon, 5 Oct 2020 12:04:44 +0530
Subject: [PATCH 084/203] Added problem #231 - Power of Two

I have added the solution class for the problem #231 -
'Power of Two'. It has runtime: 0ms and
memory usage: 6MB
---
 ONLINE JUDGE/LeetCode/#231-Power_Of_Two.cpp | 8 ++++++++
 1 file changed, 8 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#231-Power_Of_Two.cpp

diff --git a/ONLINE JUDGE/LeetCode/#231-Power_Of_Two.cpp b/ONLINE JUDGE/LeetCode/#231-Power_Of_Two.cpp
new file mode 100644
index 0000000..aae5788
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#231-Power_Of_Two.cpp	
@@ -0,0 +1,8 @@
+class Solution {
+public:
+    bool isPowerOfTwo(int n) {
+        if(n<=0)
+            return 0;
+        return !(n&(n-1));
+    }
+};
\ No newline at end of file

From 2509193053578fb3f070ecbc56f71b9ce169cd64 Mon Sep 17 00:00:00 2001
From: Aditya Parthasarathy <adityap301@gmail.com>
Date: Mon, 5 Oct 2020 12:08:05 +0530
Subject: [PATCH 085/203] Revert "Added problem #231 - Power of Two"

This reverts commit 6526240edcd1338fdfd60d9900d4c7b14090d754.
---
 ONLINE JUDGE/LeetCode/#231-Power_Of_Two.cpp | 8 --------
 1 file changed, 8 deletions(-)
 delete mode 100644 ONLINE JUDGE/LeetCode/#231-Power_Of_Two.cpp

diff --git a/ONLINE JUDGE/LeetCode/#231-Power_Of_Two.cpp b/ONLINE JUDGE/LeetCode/#231-Power_Of_Two.cpp
deleted file mode 100644
index aae5788..0000000
--- a/ONLINE JUDGE/LeetCode/#231-Power_Of_Two.cpp	
+++ /dev/null
@@ -1,8 +0,0 @@
-class Solution {
-public:
-    bool isPowerOfTwo(int n) {
-        if(n<=0)
-            return 0;
-        return !(n&(n-1));
-    }
-};
\ No newline at end of file

From 629ba9101e171a5becbd1b569e61ab89c22861cd Mon Sep 17 00:00:00 2001
From: zee-bit <equbalzeeshan@gmail.com>
Date: Mon, 5 Oct 2020 12:43:34 +0530
Subject: [PATCH 086/203] Added two new Algorithms in Bit Manipulation and
 Number Theory

---
 .../Unique Bitwise OR of subarrays.cpp        | 35 +++++++++++++++++++
 09- Number Theory/Binary Multiplication.cpp   | 25 +++++++++++++
 2 files changed, 60 insertions(+)
 create mode 100644 06-Bit Manipulation/Unique Bitwise OR of subarrays.cpp
 create mode 100644 09- Number Theory/Binary Multiplication.cpp

diff --git a/06-Bit Manipulation/Unique Bitwise OR of subarrays.cpp b/06-Bit Manipulation/Unique Bitwise OR of subarrays.cpp
new file mode 100644
index 0000000..64d5df4
--- /dev/null
+++ b/06-Bit Manipulation/Unique Bitwise OR of subarrays.cpp	
@@ -0,0 +1,35 @@
+// This algorithm finds unique Bitwise OR of
+// all the subarrays of an array.
+// The Time Complexity might look like
+// its O(n^2), but upon taking a closer look 
+// at algorithm, it comes out to be of the 
+// order of O(n)
+#include <bits/stdc++.h>
+using namespace std;
+
+int subarrayBitwiseORs(vector<int>& A) {
+    unordered_set<int> st;
+    int n = A.size(), chk = 0, curr;
+    for(int i = n - 1; i >= 0; i--) {
+        curr = A[i];
+        st.insert(curr);
+        chk = 0;
+        for(int j = i + 1; j < n && chk != curr; j++) {
+            curr |= A[j];
+            chk |= A[j];
+            st.insert(curr);
+        }
+    }
+    return st.size();
+}
+
+int main() {
+    int n;
+    cin >> n;
+    vector<int> arr(n);
+    for(int i = 0; i < n; i++) {
+        cin >> arr[i];
+    }
+    cout << subarrayBitwiseORs(arr) << endl;
+    return 0;
+}
\ No newline at end of file
diff --git a/09- Number Theory/Binary Multiplication.cpp b/09- Number Theory/Binary Multiplication.cpp
new file mode 100644
index 0000000..17c949c
--- /dev/null
+++ b/09- Number Theory/Binary Multiplication.cpp	
@@ -0,0 +1,25 @@
+// This code will have a complexity of O(log b), but
+// we can use __int128 in C++ to avoid any potential
+// overflows and work in O(1).
+#include <bits/stdc++.h>
+using namespace std;
+typedef long long ll;
+
+ll binaryMultiplication(ll a, ll b) {
+	ll x = 0, y = a;
+	while (b > 0) {
+		if (b & 1)
+			x = (x + y);
+		y = (y + y);
+		b >>= 1;
+	}
+	return x;
+}
+
+int main() {
+    ll a, b;
+    cin >> a >> b;
+    // Finding a^b
+    cout << binaryMultiplication(a, b) << endl;
+    return 0;
+}
\ No newline at end of file

From 43c2ad13b7c32fb74c38fbea88e7d2346ac58885 Mon Sep 17 00:00:00 2001
From: Jogi <venkataphanikumar.jogi@teradata.com>
Date: Mon, 5 Oct 2020 13:24:51 +0530
Subject: [PATCH 087/203] Added problem in Greedy Algorithms

---
 23- Greedy Algorithms/GasUp.cpp | 60 +++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)
 create mode 100644 23- Greedy Algorithms/GasUp.cpp

diff --git a/23- Greedy Algorithms/GasUp.cpp b/23- Greedy Algorithms/GasUp.cpp
new file mode 100644
index 0000000..82bc0ba
--- /dev/null
+++ b/23- Greedy Algorithms/GasUp.cpp	
@@ -0,0 +1,60 @@
+#include <iostream>
+#include <vector>
+using namespace std;
+/*
+Problem: https://leetcode.com/problems/gas-station/
+This is one of the best Greedy problem with small trick
+
+Approach:
+* If total gas is less than total cost, we can not complete journey wherver we start.
+* If tatal gas is >= total cost
+    * Say X is the station where it has minium amount of gas before we reach there.
+    * Since we never have less than this amount of gas we started at at X, we can start at X so that we have 0 gas at the end.
+*/
+
+int canCompleteCircuit(vector<int> &gas, vector<int> &cost)
+{
+  int stationCount = gas.size();
+  int totalGas = 0, totalCost = 0;
+  for (int ind = 0; ind < stationCount; ind++)
+  {
+    totalGas += gas[ind];
+    totalCost += cost[ind];
+  }
+  if (totalGas < totalCost)
+    return -1;
+
+  struct StartingStation
+  {
+    int stationInd = 0, remainingGas = 0;
+  };
+  StartingStation startingStationPair;
+
+  int remainingGas = 0;
+
+  for (int ind = 1; ind < stationCount; ind++)
+  {
+    remainingGas += gas[ind - 1] - cost[ind - 1];
+    if (remainingGas < startingStationPair.remainingGas)
+    {
+      startingStationPair = {ind, remainingGas};
+    }
+  }
+
+  return startingStationPair.stationInd;
+}
+
+int main()
+{
+  int stationCount;
+  cin >> stationCount;
+  vector<int> gas(stationCount), cost(stationCount);
+
+  for (int ind = 0; ind < stationCount; ind++)
+    cin >> gas[ind];
+  for (int ind = 0; ind < stationCount; ind++)
+    cin >> cost[ind];
+
+  cout << canCompleteCircuit(gas, cost) << endl;
+  return 0;
+}

From 85e822e41f23710c1c58f40aaf7b31e6935735ba Mon Sep 17 00:00:00 2001
From: Salonii02 <salonisawarkar13@gmail.com>
Date: Mon, 5 Oct 2020 13:24:55 +0530
Subject: [PATCH 088/203] Added Weighted_Job_Scheduling in Dynamic Programming

---
 .../Weighted_Job_Scheduling.cpp               | 62 +++++++++++++++++++
 1 file changed, 62 insertions(+)
 create mode 100644 24- Dynamic Programming/Weighted_Job_Scheduling.cpp

diff --git a/24- Dynamic Programming/Weighted_Job_Scheduling.cpp b/24- Dynamic Programming/Weighted_Job_Scheduling.cpp
new file mode 100644
index 0000000..c573aab
--- /dev/null
+++ b/24- Dynamic Programming/Weighted_Job_Scheduling.cpp	
@@ -0,0 +1,62 @@
+#include <bits/stdc++.h>
+using namespace std;
+#define ll long long int
+#define push_back pb
+#define pair<int,int> pp
+struct interval
+{
+    int start;
+    int finish;
+    int weight;
+};
+bool sortbyfinish(interval p1,interval p2)
+{
+	return p1.finish<p2.finish;
+}
+int nextcompatible(vector<interval> &arr;,int i)
+{
+    for (int j=i-1; j>=0; j--) 
+    { 
+        if (arr[j].finish <= arr[i].start) 
+            return j; 
+    } 
+    return -1; 
+}
+int main()
+{
+    int test;
+    cin>>test;
+    while(test--)
+    {
+    	int n;
+    	cin>>n;
+    	int start[n];
+    	int finish[n];
+        int weight[n];
+    	for(int i=0;i<n;i++)
+    		cin>>start[i];
+    	for(int i=0;i<n;i++)
+    		cin>>finish[i];
+        for(int i=0;i<n;i++)
+            cin>>weight[i];
+        vector<interval> arr;
+        for(int i=0;i<n;i++)
+        {
+            arr.push_back({start[i],finish[i],weight[i]});
+        }
+        sort(arr.begin(),arr.end(),sortbyfinish);
+        vector<int> dp(n,0);
+        dp[0]=arr[0].weight;
+        for(int i=1;i<n;i++)
+        {
+            int include=arr[i].weight;
+            int exclude=dp[i-1];
+            int findnext=nextcompatible(arr,i);
+            if(findnext!=-1)
+                include+= dp[findnext];
+            dp[i]=max(include,exclude);
+        }
+        cout<<dp[n-1]<<endl;
+    }
+        return 0;
+}
\ No newline at end of file

From eba2a2c9189033a4a108f08b9a770bddd4fd2d30 Mon Sep 17 00:00:00 2001
From: Salonii02 <salonisawarkar13@gmail.com>
Date: Mon, 5 Oct 2020 13:30:42 +0530
Subject: [PATCH 089/203] Added Job_Scheduling in Dynamic Programming

---
 24- Dynamic Programming/Job_Sheduling.cpp | 46 +++++++++++++++++++++++
 1 file changed, 46 insertions(+)
 create mode 100644 24- Dynamic Programming/Job_Sheduling.cpp

diff --git a/24- Dynamic Programming/Job_Sheduling.cpp b/24- Dynamic Programming/Job_Sheduling.cpp
new file mode 100644
index 0000000..330365f
--- /dev/null
+++ b/24- Dynamic Programming/Job_Sheduling.cpp	
@@ -0,0 +1,46 @@
+#include <bits/stdc++.h>
+using namespace std;
+#define ll long long int
+#define push_back pb
+#define pair<int,int> pp
+bool sortbyfinish(pp p1,pp p2)
+{
+	return p1.second<p2.second;
+}
+int main()
+{
+    int test;
+    cin>>test;
+    while(test--)
+    {
+    	int n;
+    	cin>>n;
+    	int start[n];
+    	int finish[n];
+    	for(int i=0;i<n;i++)
+    		cin>>start[i];
+    	for(int i=0;i<n;i++)
+    		cin>>finish[i];
+    	vector<pair<int,int>>activities;
+    	for(int i=0;i<n;i++)
+    	{
+    		activities.pb({i,finish[i]});
+    	}
+    	sort(activities.begin(),activities.end(),sortbyfinish);
+    	vector<int>ans;
+    	int i=0;  //myprevious scheduled job
+    	ans.push_back(activities[i].first);
+    	for(int j=1;j<n;j++)
+    	{
+    		int nextcompa=activities[j].first;
+    		if(start[nextcompa]>=activities[i].second)
+    		{
+    			i=j;
+    			ans.push_back(activities[i].first);
+    		}
+    	}
+        for(int i=0;i<ans.size();i++)
+        	cout<<ans[i]<<endl;
+    }
+return 0;
+}
\ No newline at end of file

From 9b89bf4d9950e4b00f6065828cc492147f8f76d1 Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Mon, 5 Oct 2020 14:56:25 +0530
Subject: [PATCH 090/203] Create c-cpp.yml

---
 .github/workflows/c-cpp.yml | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
 create mode 100644 .github/workflows/c-cpp.yml

diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml
new file mode 100644
index 0000000..e323326
--- /dev/null
+++ b/.github/workflows/c-cpp.yml
@@ -0,0 +1,23 @@
+name: C/C++ CI
+
+on:
+  push:
+    branches: [ master ]
+  pull_request:
+    branches: [ master ]
+
+jobs:
+  build:
+
+    runs-on: ubuntu-latest
+
+    steps:
+    - uses: actions/checkout@v2
+    - name: configure
+      run: ./configure
+    - name: make
+      run: make
+    - name: make check
+      run: make check
+    - name: make distcheck
+      run: make distcheck

From 01e663ddc96a3101ac870cada5feba15ee20979e Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Mon, 5 Oct 2020 14:57:23 +0530
Subject: [PATCH 091/203] Create .travis.yml

---
 .github/workflows/.travis.yml | 36 +++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
 create mode 100644 .github/workflows/.travis.yml

diff --git a/.github/workflows/.travis.yml b/.github/workflows/.travis.yml
new file mode 100644
index 0000000..e11cfe9
--- /dev/null
+++ b/.github/workflows/.travis.yml
@@ -0,0 +1,36 @@
+language: cpp
+
+compiler:
+  - clang
+  - gcc
+  -clang++
+  
+jobs:
+  fast_finish: true
+
+git:
+  submodules: false
+  
+  name: C/C++ CI
+
+on:
+  push:
+    branches: [ master ]
+  pull_request:
+    branches: [ master ]
+
+jobs:
+  build:
+
+    runs-on: ubuntu-latest
+
+    steps:
+    - uses: actions/checkout@v2
+    - name: configure
+      run: ./configure
+    - name: make
+      run: make
+    - name: make check
+      run: make check
+    - name: make distcheck
+      run: make distcheck

From 21fc07ef63f56138c166e59649bad8af8fb8ac51 Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Mon, 5 Oct 2020 14:57:38 +0530
Subject: [PATCH 092/203] Delete .travis.yml

---
 .travis.yml | 37 -------------------------------------
 1 file changed, 37 deletions(-)
 delete mode 100644 .travis.yml

diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index dbe4c53..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,37 +0,0 @@
-language: cpp
-
-compiler:
-  - clang
-  - gcc
-  -clang++
-  
-jobs:
-  fast_finish: true
-
-git:
-  submodules: false
-  
-  name: C/C++ CI
-
-on:
-  push:
-    branches: [ master ]
-  pull_request:
-    branches: [ master ]
-
-jobs:
-  build:
-
-    runs-on: ubuntu-latest
-
-    steps:
-    - uses: actions/checkout@v2
-    - name: configure
-      run: ./configure
-    - name: make
-      run: make
-    - name: make check
-      run: make check
-    - name: make distcheck
-      run: make distcheck
-

From 3220a8c294bb50d3959ee9e23c1663d903a8160c Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Mon, 5 Oct 2020 15:19:11 +0530
Subject: [PATCH 093/203] Delete .travis.yml

---
 .github/workflows/.travis.yml | 36 -----------------------------------
 1 file changed, 36 deletions(-)
 delete mode 100644 .github/workflows/.travis.yml

diff --git a/.github/workflows/.travis.yml b/.github/workflows/.travis.yml
deleted file mode 100644
index e11cfe9..0000000
--- a/.github/workflows/.travis.yml
+++ /dev/null
@@ -1,36 +0,0 @@
-language: cpp
-
-compiler:
-  - clang
-  - gcc
-  -clang++
-  
-jobs:
-  fast_finish: true
-
-git:
-  submodules: false
-  
-  name: C/C++ CI
-
-on:
-  push:
-    branches: [ master ]
-  pull_request:
-    branches: [ master ]
-
-jobs:
-  build:
-
-    runs-on: ubuntu-latest
-
-    steps:
-    - uses: actions/checkout@v2
-    - name: configure
-      run: ./configure
-    - name: make
-      run: make
-    - name: make check
-      run: make check
-    - name: make distcheck
-      run: make distcheck

From 8f2ae768dc913b48aad7afbc7daab91b72c9de8a Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Mon, 5 Oct 2020 15:20:51 +0530
Subject: [PATCH 094/203] Create .travis.yml

---
 .travis.yml | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100644 .travis.yml

diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..8a1a256
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,26 @@
+language: cpp
+
+compiler:
+  - clang
+  - gcc
+  -clang++
+  
+jobs:
+  fast_finish: true
+
+git:
+  submodules: false
+  
+  name: C/C++ CI
+
+on:
+  push:
+    branches: [ master ]
+  pull_request:
+    branches: [ master ]
+
+jobs:
+  build:
+
+    runs-on: ubuntu-latest
+

From d5d76e3f1d40d6014587e957a0bbd1a1dedb50f4 Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Mon, 5 Oct 2020 15:21:11 +0530
Subject: [PATCH 095/203] Update .travis.yml

---
 .travis.yml | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 8a1a256..9e87d2c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -10,9 +10,6 @@ jobs:
 
 git:
   submodules: false
-  
-  name: C/C++ CI
-
 on:
   push:
     branches: [ master ]

From 32e280bbd5520f66f3d76360f1d21351139775d7 Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Mon, 5 Oct 2020 15:31:32 +0530
Subject: [PATCH 096/203] Delete .travis.yml

---
 .travis.yml | 23 -----------------------
 1 file changed, 23 deletions(-)
 delete mode 100644 .travis.yml

diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 9e87d2c..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,23 +0,0 @@
-language: cpp
-
-compiler:
-  - clang
-  - gcc
-  -clang++
-  
-jobs:
-  fast_finish: true
-
-git:
-  submodules: false
-on:
-  push:
-    branches: [ master ]
-  pull_request:
-    branches: [ master ]
-
-jobs:
-  build:
-
-    runs-on: ubuntu-latest
-

From d18fb833f838ea063ac858ccbc2e2e879be83c1e Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Mon, 5 Oct 2020 15:31:48 +0530
Subject: [PATCH 097/203] Delete c-cpp.yml

---
 .github/workflows/c-cpp.yml | 23 -----------------------
 1 file changed, 23 deletions(-)
 delete mode 100644 .github/workflows/c-cpp.yml

diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml
deleted file mode 100644
index e323326..0000000
--- a/.github/workflows/c-cpp.yml
+++ /dev/null
@@ -1,23 +0,0 @@
-name: C/C++ CI
-
-on:
-  push:
-    branches: [ master ]
-  pull_request:
-    branches: [ master ]
-
-jobs:
-  build:
-
-    runs-on: ubuntu-latest
-
-    steps:
-    - uses: actions/checkout@v2
-    - name: configure
-      run: ./configure
-    - name: make
-      run: make
-    - name: make check
-      run: make check
-    - name: make distcheck
-      run: make distcheck

From e0b3b25ae5b1439d98faa7b812376930939dd094 Mon Sep 17 00:00:00 2001
From: Salonii02 <salonisawarkar13@gmail.com>
Date: Mon, 5 Oct 2020 16:13:13 +0530
Subject: [PATCH 098/203] Updated Solution for Scheduling problems

---
 .../{Job_Sheduling.cpp => Job_Scheduling.cpp}             | 8 ++++----
 24- Dynamic Programming/Weighted_Job_Scheduling.cpp       | 7 ++++---
 2 files changed, 8 insertions(+), 7 deletions(-)
 rename 24- Dynamic Programming/{Job_Sheduling.cpp => Job_Scheduling.cpp} (86%)

diff --git a/24- Dynamic Programming/Job_Sheduling.cpp b/24- Dynamic Programming/Job_Scheduling.cpp
similarity index 86%
rename from 24- Dynamic Programming/Job_Sheduling.cpp
rename to 24- Dynamic Programming/Job_Scheduling.cpp
index 330365f..3697451 100644
--- a/24- Dynamic Programming/Job_Sheduling.cpp	
+++ b/24- Dynamic Programming/Job_Scheduling.cpp	
@@ -1,8 +1,8 @@
 #include <bits/stdc++.h>
 using namespace std;
 #define ll long long int
-#define push_back pb
-#define pair<int,int> pp
+#define pb push_back
+#define pp pair <int,int>
 bool sortbyfinish(pp p1,pp p2)
 {
 	return p1.second<p2.second;
@@ -39,8 +39,8 @@ int main()
     			ans.push_back(activities[i].first);
     		}
     	}
-        for(int i=0;i<ans.size();i++)
-        	cout<<ans[i]<<endl;
+        cout<<"No.of Jobs that can be scheduled : "<<endl;
+        cout<<ans.size()<<endl;
     }
 return 0;
 }
\ No newline at end of file
diff --git a/24- Dynamic Programming/Weighted_Job_Scheduling.cpp b/24- Dynamic Programming/Weighted_Job_Scheduling.cpp
index c573aab..db7b4dd 100644
--- a/24- Dynamic Programming/Weighted_Job_Scheduling.cpp	
+++ b/24- Dynamic Programming/Weighted_Job_Scheduling.cpp	
@@ -1,8 +1,8 @@
 #include <bits/stdc++.h>
 using namespace std;
 #define ll long long int
-#define push_back pb
-#define pair<int,int> pp
+#define pb push_back 
+#define pp pair<int,int>
 struct interval
 {
     int start;
@@ -13,7 +13,7 @@ bool sortbyfinish(interval p1,interval p2)
 {
 	return p1.finish<p2.finish;
 }
-int nextcompatible(vector<interval> &arr;,int i)
+int nextcompatible(vector<interval> &arr,int i)
 {
     for (int j=i-1; j>=0; j--) 
     { 
@@ -56,6 +56,7 @@ int main()
                 include+= dp[findnext];
             dp[i]=max(include,exclude);
         }
+        cout<<"Maximum profit that can be obtained : "<<endl;
         cout<<dp[n-1]<<endl;
     }
         return 0;

From 9a8ecf936153a5c46c963e3767266efc9b320e34 Mon Sep 17 00:00:00 2001
From: Jogi <venkataphanikumar.jogi@teradata.com>
Date: Mon, 5 Oct 2020 16:24:28 +0530
Subject: [PATCH 099/203] Merge sort algorithm added

MergeSort algorithm added
---
 04-Sorting/MergeSort.cpp | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 04-Sorting/MergeSort.cpp

diff --git a/04-Sorting/MergeSort.cpp b/04-Sorting/MergeSort.cpp
new file mode 100644
index 0000000..bfb86f6
--- /dev/null
+++ b/04-Sorting/MergeSort.cpp
@@ -0,0 +1,35 @@
+/*
+* Merge sort algorithm works on divide and conquer concept
+* This code shows divide and conquer steps in two different functions separately
+*/
+#include<iostream>
+#include<vector>
+using namespace std;
+
+void merging(vector<int> &ar,int low,int mid,int high){
+	int I=low,J=mid+1,K=0,br[10000];
+	while(I<=mid && J<=high) br[K++] = ar[I]<=ar[J] ? ar[I++] : ar[J++];
+	while(I<=mid) br[K++]=ar[I++];
+	while(J<=high) br[K++]=ar[J++];
+	while(--K>=0) ar[low+K]=br[K];
+}
+
+void merg_sort(vector<int> &ar,int low,int high){
+	if(low<high){
+		int mid = (low+high)/2;
+		merg_sort(ar,low,mid);
+		merg_sort(ar,mid+1,high);
+		merging(ar,low,mid,high);
+	}
+}
+
+int main(){
+	int n;
+	cin >> n;
+	vector<int> ar(n);
+	for(int I=0;I<n;I++) cin >> ar[I];
+
+	merg_sort(ar,0,n-1);
+	for(int I=0;I<n;I++) cout << ar[I] << " ";
+	return 0;
+}

From be4b225f5c9c4dfc780101882350baa37e3c3233 Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Mon, 5 Oct 2020 21:15:17 +0530
Subject: [PATCH 100/203] Update README.md

---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index f4c1cc8..c1f2840 100644
--- a/README.md
+++ b/README.md
@@ -9,7 +9,7 @@
  <img src=./mobxtree.png>
  </p>
 
-# Cpp DSA
+# C++ DSA 
 Repo contains some most common Data Structure and Algorithm in cpp. Which will useful in future application of Competitive Programming as well Interview Preparation.
 
 

From 3b891a6e99d17f9d8a9d5e57b0232e3f31982d4a Mon Sep 17 00:00:00 2001
From: dev9414 <46513305+dev9414@users.noreply.github.com>
Date: Mon, 5 Oct 2020 08:50:06 -0700
Subject: [PATCH 101/203] Create subsetsum.cpp

---
 24- Dynamic Programming/subsetsum.cpp | 41 +++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
 create mode 100644 24- Dynamic Programming/subsetsum.cpp

diff --git a/24- Dynamic Programming/subsetsum.cpp b/24- Dynamic Programming/subsetsum.cpp
new file mode 100644
index 0000000..bedc57d
--- /dev/null
+++ b/24- Dynamic Programming/subsetsum.cpp	
@@ -0,0 +1,41 @@
+// A recursive solution for subset sum problem 
+#include <stdio.h> 
+
+// Returns true if there is a subset 
+// of set[] with sum equal to given sum 
+bool isSubsetSum(int set[], int n, int sum) 
+{ 
+	// Base Cases 
+	if (sum == 0) 
+		return true; 
+	if (n == 0) 
+		return false; 
+
+	// If last element is greater than sum, 
+	// then ignore it 
+	if (set[n - 1] > sum) 
+		return isSubsetSum(set, n - 1, sum); 
+
+	/* else, check if sum can be obtained by any 
+of the following: 
+	(a) including the last element 
+	(b) excluding the last element */
+	return isSubsetSum(set, n - 1, sum) 
+		|| isSubsetSum(set, n - 1, sum - set[n - 1]); 
+} 
+
+// Driver program to test above function 
+int main() 
+{ int n;
+cin>>n;
+	int set[n]; 
+	int sum ;
+  
+  cin>>sum
+
+	if (isSubsetSum(set, n, sum) == true) 
+		printf("Found a subset with given sum"); 
+	else
+		printf("No subset with given sum"); 
+	return 0; 
+} 

From 18c7810f93906b9ac4715542417e3698b0465877 Mon Sep 17 00:00:00 2001
From: dev9414 <46513305+dev9414@users.noreply.github.com>
Date: Mon, 5 Oct 2020 09:31:59 -0700
Subject: [PATCH 102/203] Create
 perfect-sum-problem-print-subsets-given-sum.cpp

---
 ...ct-sum-problem-print-subsets-given-sum.cpp | 88 +++++++++++++++++++
 1 file changed, 88 insertions(+)
 create mode 100644 24- Dynamic Programming/perfect-sum-problem-print-subsets-given-sum.cpp

diff --git a/24- Dynamic Programming/perfect-sum-problem-print-subsets-given-sum.cpp b/24- Dynamic Programming/perfect-sum-problem-print-subsets-given-sum.cpp
new file mode 100644
index 0000000..e1c9451
--- /dev/null
+++ b/24- Dynamic Programming/perfect-sum-problem-print-subsets-given-sum.cpp	
@@ -0,0 +1,88 @@
+// C++ program to count all subsets with 
+// given sum. 
+#include <bits/stdc++.h> 
+using namespace std; 
+
+bool** dp; 
+
+void display(const vector<int>& v) 
+{ 
+	for (int i = 0; i < v.size(); ++i) 
+		printf("%d ", v[i]); 
+	printf("\n"); 
+} 
+
+void printSubsetsRec(int arr[], int i, int sum, vector<int>& p) 
+{ 
+	
+	if (i == 0 && sum != 0 && dp[0][sum]) 
+	{ 
+		p.push_back(arr[i]); 
+		display(p); 
+		return; 
+	} 
+
+	// If sum becomes 0 
+	if (i == 0 && sum == 0) 
+	{ 
+		display(p); 
+		return; 
+	} 
+
+	if (dp[i-1][sum]) 
+	{ 
+ 
+		vector<int> b = p; 
+		printSubsetsRec(arr, i-1, sum, b); 
+	} 
+
+
+	if (sum >= arr[i] && dp[i-1][sum-arr[i]]) 
+	{ 
+		p.push_back(arr[i]); 
+		printSubsetsRec(arr, i-1, sum-arr[i], p); 
+	} 
+} 
+
+void printAllSubsets(int arr[], int n, int sum) 
+{ 
+	if (n == 0 || sum < 0) 
+	return; 
+
+	// Sum 0 can always be achieved with 0 elements 
+	dp = new bool*[n]; 
+	for (int i=0; i<n; ++i) 
+	{ 
+		dp[i] = new bool[sum + 1]; 
+		dp[i][0] = true; 
+	} 
+
+
+	if (arr[0] <= sum) 
+	dp[0][arr[0]] = true; 
+
+	for (int i = 1; i < n; ++i) 
+		for (int j = 0; j < sum + 1; ++j) 
+			dp[i][j] = (arr[i] <= j) ? dp[i-1][j] || 
+									dp[i-1][j-arr[i]] 
+									: dp[i - 1][j]; 
+	if (dp[n-1][sum] == false) 
+	{ 
+		printf("There are no subsets with sum %d\n", sum); 
+		return; 
+	} 
+
+	vector<int> p; 
+	printSubsetsRec(arr, n-1, sum, p); 
+} 
+
+
+int main() 
+{ int n;
+cin>>n;
+	int arr[n]; 
+	int sum; 
+  cin>>sum;
+	printAllSubsets(arr, n, sum); 
+	return 0; 
+} 

From 1e23bb167a65a049f3fb6572c1b805419e089632 Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Tue, 6 Oct 2020 01:29:38 +0530
Subject: [PATCH 103/203] Update ReadMe.md

---
 ONLINE JUDGE/LeetCode/ReadMe.md | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/ONLINE JUDGE/LeetCode/ReadMe.md b/ONLINE JUDGE/LeetCode/ReadMe.md
index 6de71e9..eebf819 100644
--- a/ONLINE JUDGE/LeetCode/ReadMe.md	
+++ b/ONLINE JUDGE/LeetCode/ReadMe.md	
@@ -1,7 +1,8 @@
 ### Add LeetCode Challenges on CPP 
 
-Make Sure to read the ReadMe.md Before making PR
+Make Sure to read the ReadMe.md Before making PR :bowtie:
 
  - <Filename> Use #LeetCode Challenge No.(Problem No.) followed by Problem Name
  - <Filename> should not have *Naming Collision*
+ - Write Complete Code(if Possible).Only Function_signature is mandatory but not permissible.
   

From 489fd755e1e9280caf31b8cf03e393209dee6477 Mon Sep 17 00:00:00 2001
From: Aditya Parthasarathy <42689525+adityap301@users.noreply.github.com>
Date: Tue, 6 Oct 2020 12:37:47 +0530
Subject: [PATCH 104/203] Added two more LeetCode problems (#81)

---
 ONLINE JUDGE/LeetCode/#231-Power_Of_Two.cpp  | 30 +++++++++++++++++
 ONLINE JUDGE/LeetCode/#342-Power_Of_Four.cpp | 34 ++++++++++++++++++++
 2 files changed, 64 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#231-Power_Of_Two.cpp
 create mode 100644 ONLINE JUDGE/LeetCode/#342-Power_Of_Four.cpp

diff --git a/ONLINE JUDGE/LeetCode/#231-Power_Of_Two.cpp b/ONLINE JUDGE/LeetCode/#231-Power_Of_Two.cpp
new file mode 100644
index 0000000..2a74cc3
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#231-Power_Of_Two.cpp	
@@ -0,0 +1,30 @@
+#include <bits/stdc++.h>
+
+using namespace std;
+
+class Solution {
+public:
+    bool isPowerOfTwo(int n) {
+        // Check for negative numbers
+        if(n<=0)
+            return 0;
+        // We can check whether a number is a power of 2, by ANDing 
+        // each bit of the number n with each corresponding bit of (n-1).
+        // If the reusult of the operation is 0, the n is a power of 2, else it is not.
+        // For e.g., let n = 8 = 0b1000
+        // Hence, n-1 = 7 = 0b0111
+        // ANDing each bit, we get 0b0000 = 0. Hence, 8 is a power of 2.
+        // Hence, return !0 = 1.
+        return !(n&(n-1));
+    }
+};
+
+int main() {
+    int num;
+    bool res;
+    Solution sol;
+    cin>>num;
+    res = sol.isPowerOfTwo(num);
+    cout<<res<<endl;
+    return 0;
+}
\ No newline at end of file
diff --git a/ONLINE JUDGE/LeetCode/#342-Power_Of_Four.cpp b/ONLINE JUDGE/LeetCode/#342-Power_Of_Four.cpp
new file mode 100644
index 0000000..3df9533
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#342-Power_Of_Four.cpp	
@@ -0,0 +1,34 @@
+#include <bits/stdc++.h>
+
+using namespace std;
+
+class Solution {
+public:
+    bool isPowerOfFour(int num) {
+        // Check for positive numbers.
+        if(num >= 0)
+            return ((num & (num-1))==0 && (num & 0b1010101010101010101010101010101) != 0);
+        // We can check whether a number is a power of 2, by ANDing 
+        // each bit of the number n with each corresponding bit of (n-1).
+        // If the reusult of the operation is 0, the n is a power of 2, else it is not.
+        // For e.g., let n = 8 = 0b1000
+        // Hence, n-1 = 7 = 0b0111
+        // ANDing each bit, we get 0b0000 = 0. Hence, 8 is a power of 2.
+        // 1010101010101010101010101010101 is a mask to check odd powers of 2, i.e., 1's in odd position.
+        // If the ANDing operation of the number and the mask returns 0, then it is an odd power.
+        // Even powers of 2 = powers of 4. If it is an odd power, we reject that answer.
+        // For e.g., 0b1000 AND 0b0101 = 0 => the condition (num & mask) becomes false and 0 is returned.
+        else
+            return false;
+    }
+};
+
+int main() {
+    int num;
+    bool res;
+    Solution sol;
+    cin>>num;
+    res = sol.isPowerOfFour(num);
+    cout<<res<<endl;
+    return 0;
+}
\ No newline at end of file

From 6a0eb1dda6d010028d242e8575ce84f3a97f098c Mon Sep 17 00:00:00 2001
From: Sharvari Raut <sharuraut7blog@gmail.com>
Date: Tue, 6 Oct 2020 17:02:18 +0530
Subject: [PATCH 105/203] Minimum Sum Partition.cpp added

---
 .../Minimum_Sum_Partition.cpp                 | 73 +++++++++++++++++++
 1 file changed, 73 insertions(+)
 create mode 100644 24- Dynamic Programming/Minimum_Sum_Partition.cpp

diff --git a/24- Dynamic Programming/Minimum_Sum_Partition.cpp b/24- Dynamic Programming/Minimum_Sum_Partition.cpp
new file mode 100644
index 0000000..260450c
--- /dev/null
+++ b/24- Dynamic Programming/Minimum_Sum_Partition.cpp	
@@ -0,0 +1,73 @@
+  
+// Minimum Sum Partition
+#include <iostream>
+#include <string>
+using namespace std;
+
+/* Partition the Set into two subsets Set1, Set2 such that the
+  difference between the sum of elements in Set1 and the sum
+  of elements in Set2 is minimized */
+int minPartition(int Set[], int n, int Set1, int Set2)
+{
+    /* Case 0. If list becomes empty, return the absolute
+       difference between two sets */
+    if (n < 0)
+        return abs(Set1 - Set2);
+
+    /* Case 1. Include current item in the subset Se1 and recur
+       for remaining items (n - 1) */
+    int inc = minPartition(Set, n - 1, Set1 + Set[n], Set2);
+
+    /* Case 2. Exclude current item from subset Se1 and recur for
+       remaining items (n - 1) */
+    int exc = minPartition(Set, n - 1, Set1, Set2 + Set[n]);
+
+    //Returning included and excluded values
+    return min(inc, exc);
+}
+
+//Main Code
+int main()
+{
+
+    //int Set[] = { 10, 20, 15, 5, 25};
+
+    int size;
+    std::cout << "Enter the number of elements you want in Set: ";
+    std::cin >> size;
+    int Set[size]; //Creating Set of size 'size'
+    std::cout << "Enter elements: " << std::endl;
+
+    for (int i = 0; i < size; i++) //Enter the elements in the Set
+    {
+        std::cin >> Set[i];
+    }
+    // Number of elements
+    int n = sizeof(Set) / sizeof(Set[0]);
+
+    cout << "\nThe entered elements in the Set are: \n" << std::endl;
+    for (int i = 0; i < size; ++i) {
+        cout << Set[i] << " ";
+    }
+    //Printing the minimum difference
+    cout << "\nThe minimum difference is " << minPartition(Set, n - 1, 0, 0);
+
+    return 0;
+}
+
+/*
+SAMPLE INPUT:
+5
+1
+2
+3
+4
+5
+SAMPLE OUTPUT:
+Enter the number of elements you want in Set: Enter elements: 
+The entered elements in the Set are: 
+1 2 3 4 5 
+The minimum difference is 1
+Time Complexity = O(n*sum) 
+Depends on the value of 'n' and 'sum'
+*/

From 5ac34a107bd4ef409e4b510a842a205ba25eda55 Mon Sep 17 00:00:00 2001
From: gilnuss9 <gilnussmail@gmail.com>
Date: Wed, 7 Oct 2020 15:59:30 +0300
Subject: [PATCH 106/203] added three LeetCode problems

---
 .../LeetCode/#21-Merge-Two-Sorted-Lists.cpp   | 27 +++++++++++++++++++
 ...26-Remove-Duplicates-From-Sorted-Array.cpp | 24 +++++++++++++++++
 ONLINE JUDGE/LeetCode/#27-Remove-Element.cpp  | 20 ++++++++++++++
 3 files changed, 71 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#21-Merge-Two-Sorted-Lists.cpp
 create mode 100644 ONLINE JUDGE/LeetCode/#26-Remove-Duplicates-From-Sorted-Array.cpp
 create mode 100644 ONLINE JUDGE/LeetCode/#27-Remove-Element.cpp

diff --git a/ONLINE JUDGE/LeetCode/#21-Merge-Two-Sorted-Lists.cpp b/ONLINE JUDGE/LeetCode/#21-Merge-Two-Sorted-Lists.cpp
new file mode 100644
index 0000000..63b6259
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#21-Merge-Two-Sorted-Lists.cpp	
@@ -0,0 +1,27 @@
+/**
+ * Definition for singly-linked list.
+ * struct ListNode {
+ *     int val;
+ *     ListNode *next;
+ *     ListNode() : val(0), next(nullptr) {}
+ *     ListNode(int x) : val(x), next(nullptr) {}
+ *     ListNode(int x, ListNode *next) : val(x), next(next) {}
+ * };
+ * 
+ * This is a Recursive soloution for this question
+ */
+
+class Solution {
+public:
+    ListNode* mergeTwoLists(ListNode* l1, ListNode* l2) {
+        if(!l1) return l2;
+        if(!l2) return l1;
+        if(l2->val > l1->val) 
+        {
+            l1->next = mergeTwoLists(l1->next,l2);
+            return l1;
+        }
+        else l2->next = mergeTwoLists(l1,l2->next);
+        return l2;
+    }
+};
\ No newline at end of file
diff --git a/ONLINE JUDGE/LeetCode/#26-Remove-Duplicates-From-Sorted-Array.cpp b/ONLINE JUDGE/LeetCode/#26-Remove-Duplicates-From-Sorted-Array.cpp
new file mode 100644
index 0000000..aaf6c36
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#26-Remove-Duplicates-From-Sorted-Array.cpp	
@@ -0,0 +1,24 @@
+/*This is an iterative soloution.
+    we go over each individual number and see if the following number in the array is identical or not.
+    if it is we use the erase function of vectors.
+    we return the size of the the array at the end.
+*/
+
+class Solution {
+public:
+    int removeDuplicates(vector<int>& nums) {
+        if(nums.size() == 0){
+            return 0;
+        }
+        if(nums.size() == 1){
+            return 1;
+        }
+        for(int i=0;i<nums.size()-1;i++){
+            if(nums.at(i) == nums.at(i+1)){
+                nums.erase(nums.begin()+i);
+                i--;
+            }
+        }
+        return nums.size(); 
+    }
+};
\ No newline at end of file
diff --git a/ONLINE JUDGE/LeetCode/#27-Remove-Element.cpp b/ONLINE JUDGE/LeetCode/#27-Remove-Element.cpp
new file mode 100644
index 0000000..8e2c971
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#27-Remove-Element.cpp	
@@ -0,0 +1,20 @@
+/*This is an iterative soloution.
+   check if the next item in the array is the searched number, if it is we delete and return the size of the new array.
+*/
+
+class Solution {
+public:
+    int removeElement(vector<int>& nums, int val) {
+         if(nums.size() == 0){
+            return 0;
+        }
+
+        for(int i=0;i<nums.size();i++){
+            if(nums[i] == val){
+                nums.erase(nums.begin()+i);
+                i--;
+            }
+        }
+        return nums.size(); 
+    }
+};
\ No newline at end of file

From 208e9fcfaf480b76f488b5b7e9089c1260442ba5 Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Sat, 10 Oct 2020 23:48:49 +0530
Subject: [PATCH 107/203] Create no_of_palindromic_path_in_string.cpp

---
 .../no_of_palindromic_path_in_string.cpp      | 23 +++++++++++++++++++
 1 file changed, 23 insertions(+)
 create mode 100644 24- Dynamic Programming/no_of_palindromic_path_in_string.cpp

diff --git a/24- Dynamic Programming/no_of_palindromic_path_in_string.cpp b/24- Dynamic Programming/no_of_palindromic_path_in_string.cpp
new file mode 100644
index 0000000..7909a39
--- /dev/null
+++ b/24- Dynamic Programming/no_of_palindromic_path_in_string.cpp	
@@ -0,0 +1,23 @@
+ #include<bits/stdc++.h>
+ using namespace std;
+ #define n 3
+ #define m 4
+int dp[n+1][m+1][n+1][m+1];
+string s[n];
+int path(int bi, int bj, int ci, int cj){
+  if(bi>ci or bj>cj  or s[bi-1][bj-1]!= s[ci-1][cj-1]) return 0; 
+  if(abs(bi-ci) + abs(bj-cj)==1) return 1;
+  if(dp[bi][bj][ci][cj]!=-1) return dp[bi][bj][ci][cj];
+  return dp[bi][bj][ci][cj]= path(bi+1,bj,ci-1,cj)+ path(bi+1,bj, ci,cj-1)
+                              + path(bi,bj+1,ci-1,cj)+ path(bi, bj+1, ci,cj-1);
+
+}                              
+
+int main(){
+s[0]= "aaab", s[1]= "baaa", s[2]= "abba";
+memset(dp,-1, sizeof(dp));
+path(1,1,n,m); 
+cout<<dp[1][1][n][m]<<endl;
+
+ return 0;
+ }

From 7dcf4a17a5155b43c09e1c4a875ca04c479f567b Mon Sep 17 00:00:00 2001
From: dhruvinfo28 <dhruv.info28@gmail.com>
Date: Sun, 11 Oct 2020 00:33:03 +0530
Subject: [PATCH 108/203] LeetCode problem 628 solution added

---
 .../#628-MaximumProductOfThreeNumbers.cpp     | 37 +++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#628-MaximumProductOfThreeNumbers.cpp

diff --git a/ONLINE JUDGE/LeetCode/#628-MaximumProductOfThreeNumbers.cpp b/ONLINE JUDGE/LeetCode/#628-MaximumProductOfThreeNumbers.cpp
new file mode 100644
index 0000000..4011dc0
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#628-MaximumProductOfThreeNumbers.cpp	
@@ -0,0 +1,37 @@
+#include<bits/stdc++.h>
+using namespace std;
+//This function below is the solution to the problem
+int maximumProduct(vector<int>& nums) {
+        int p1,p2;
+        int max1,max2,max3,small1,small2;
+        max1=max2=max3=-1001;
+         small1=small2=1001;
+        for(int i=0;i<nums.size();i++){
+            if(nums[i]>=max3){
+                max1=max2;
+                max2=max3;
+                max3=nums[i];
+            }else if(nums[i]>=max2){
+                max1=max2;
+                max2=nums[i];
+            }else if(nums[i]>=max1){
+                max1=nums[i];
+            }
+            
+            if(nums[i]<=small1){
+                small2=small1;
+                small1=nums[i];
+            }else if(nums[i]<=small2){
+                small2=nums[i];
+            }
+        }
+        p1=max1*max2*max3;
+        p2 = small1*small2*max3;
+        return max(p1,p2);
+}
+//Driver Code
+int main(){
+    vector <int> nums = {1,2,3};
+    cout<<maximumProduct(nums);
+return 0;
+}
\ No newline at end of file

From feedc8468170a4c5dbc19927c9e0d27669f34300 Mon Sep 17 00:00:00 2001
From: shrekcodes <57681470+shrekcodes@users.noreply.github.com>
Date: Sun, 18 Oct 2020 15:29:04 +0530
Subject: [PATCH 109/203] Create #413-Airthmatic_slices.cpp

---
 .../LeetCode/#413-Airthmatic_slices.cpp       | 68 +++++++++++++++++++
 1 file changed, 68 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#413-Airthmatic_slices.cpp

diff --git a/ONLINE JUDGE/LeetCode/#413-Airthmatic_slices.cpp b/ONLINE JUDGE/LeetCode/#413-Airthmatic_slices.cpp
new file mode 100644
index 0000000..2ec901e
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#413-Airthmatic_slices.cpp	
@@ -0,0 +1,68 @@
+/*************************************************************************************** 
+ *
+ * A sequence of number is called arithmetic if it consists of at least three elements 
+ * and if the difference between any two consecutive elements is the same.
+ * 
+ * For example, these are arithmetic sequence:
+ * 1, 3, 5, 7, 9
+ * 7, 7, 7, 7
+ * 3, -1, -5, -9
+ * 
+ * The following sequence is not arithmetic. 1, 1, 2, 5, 7 
+ * 
+ * A zero-indexed array A consisting of N numbers is given. A slice of that array is 
+ * any pair of integers (P, Q) such that 0 
+ * 
+ * A slice (P, Q) of array A is called arithmetic if the sequence:
+ *     A[P], A[p + 1], ..., A[Q - 1], A[Q] is arithmetic. In particular, this means 
+ * that P + 1 
+ * 
+ * The function should return the number of arithmetic slices in the array A. 
+ * 
+ * Example:
+ * 
+ * A = [1, 2, 3, 4]
+ * 
+ * return: 3, for 3 arithmetic slices in A: [1, 2, 3], [2, 3, 4] and [1, 2, 3, 4] 
+ * itself.
+ ***************************************************************************************/
+
+class Solution {
+public:
+    //
+    // It's easy to find out how many 3-length slices in an arithmetic array with N length.
+    //
+    //   len = 3, then  1 slices, sum(1)
+    //   len = 4, then  3 slices, sum(1,2) - TWO 3-length slices + ONE 4-length slice
+    //   len = 5, then  6 slices, sum(1,2,3) - THREE 3-length slices + TWO 4-length slices + ONE 5-length slice
+    //   len = 6, then 10 slices, sum(1,2,3,4) - ...
+    //   len = 7, then 15 slices, sum(1,2,3,4,5) - ..
+    //
+    // So, with N length arithmetic array, there are Sum[1, N-3+1] 3-length slices
+    //
+    // And, we know the formula sum from 1 to n is:
+    //
+    //                  n * ( n + 1 )
+    //    sum [1, n] = ---------------
+    //                       2
+    // Then, we could have the solution - O(n) Time with O(1) Space
+    //
+    
+    int sum1toN(int n) {
+        return n * (n+1) / 2;
+    }
+
+    int numberOfArithmeticSlices(vector<int>& A) {
+        int result = 0;
+        int len = 0; // the current length of arithmetic
+        for (int i=2; i<A.size(); i++) {
+            if (A[i] - A[i-1] == A[i-1] - A[i-2]) {
+                len++;
+            }else{
+                result += sum1toN(len);
+                len=0;
+            }
+        }
+        return len==0 ? result : result + sum1toN(len);
+    }
+};

From 309216aab91b13ae6ae8604f2f60307344595a6f Mon Sep 17 00:00:00 2001
From: shrekcodes <57681470+shrekcodes@users.noreply.github.com>
Date: Sun, 18 Oct 2020 15:47:09 +0530
Subject: [PATCH 110/203] Create #89- Gray_Code.cpp

---
 ONLINE JUDGE/LeetCode/#89- Gray_Code.cpp | 146 +++++++++++++++++++++++
 1 file changed, 146 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#89- Gray_Code.cpp

diff --git a/ONLINE JUDGE/LeetCode/#89- Gray_Code.cpp b/ONLINE JUDGE/LeetCode/#89- Gray_Code.cpp
new file mode 100644
index 0000000..b33cd07
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#89- Gray_Code.cpp	
@@ -0,0 +1,146 @@
+* The gray code is a binary numeral system where two successive values differ in only one bit.
+* 
+* Given a non-negative integer n representing the total number of bits in the code, 
+* print the sequence of gray code. A gray code sequence must begin with 0.
+* 
+* For example, given n = 2, return [0,1,3,2]. Its gray code sequence is:
+* 
+* 00 - 0
+* 01 - 1
+* 11 - 3
+* 10 - 2
+* 
+* Note:
+* For a given n, a gray code sequence is not uniquely defined.
+* 
+* For example, [0,2,3,1] is also a valid gray code sequence according to the above definition.
+* 
+* For now, the judge is able to judge based on one instance of gray code sequence. Sorry about that.
+*               
+**********************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <iostream>
+#include <vector>
+using namespace std;
+
+/*
+ * I designed the following stupid algorithm base on the blow observation
+ * 
+ * I noticed I can use a `mirror-like` binary tree to figure out the gray code.
+ * 
+ * For example:
+ * 
+ *           0      
+ *        __/ \__   
+ *       0       1  
+ *      / \     / \ 
+ *     0   1   1   0
+ * So, the gray code as below: (top-down, from left to right)
+ *
+ *     0 0 0 
+ *     0 0 1
+ *     0 1 1
+ *     0 1 0
+ * 
+ *                  0
+ *            _____/ \_____
+ *           0             1
+ *        __/ \__       __/ \__
+ *       0       1     1       0
+ *      / \     / \   / \     / \
+ *     0   1   1   0 0   1   1   0
+ * 
+ * So, the gray code as below:
+ *
+ *     0 0 0 0 
+ *     0 0 0 1
+ *     0 0 1 1
+ *     0 0 1 0
+ *     0 1 1 0
+ *     0 1 1 1 
+ *     0 1 0 1
+ *     0 1 0 0
+ */
+vector<int> grayCode01(int n) {
+    vector<int> v;
+    //n = 1<<n;
+    
+    int x =0;   
+    v.push_back(x); 
+    for(int i=0; i<n; i++){
+        int len = v.size();
+        for (int j=0; j<len; j++){
+            x = v[j]<<1;
+            if (j%2==0){
+                v.push_back(x);
+                v.push_back(x+1);
+            }else{
+                v.push_back(x+1);
+                v.push_back(x);
+            }
+        }
+        v.erase(v.begin(), v.begin()+len);
+    }
+     
+    return v;
+}
+
+/*
+ * Actually, there is a better way.
+ * The mathematical way is: (num >> 1) ^ num; 
+ * Please refer to http://en.wikipedia.org/wiki/Gray_code
+ */
+vector<int> grayCode02(int n) {
+    vector<int> ret;   
+    int size = 1 << n;   
+    for(int i = 0; i < size; ++i) {
+        ret.push_back((i >> 1)^i);   
+    }
+    return ret;   
+}
+
+//random invoker
+vector<int> grayCode(int n) {
+    srand(time(0));
+    if (rand()%2){
+        return grayCode01(n);
+    }
+    return grayCode02(n);
+}
+
+void printBits(int n, int len){
+    for(int i=len-1; i>=0; i--) {
+        if (n & (1<<i)) {
+            printf("1");
+        }else{
+            printf("0");
+        }
+    }
+}
+
+void printVector(vector<int>& v, int bit_len)
+{
+    vector<int>::iterator it;
+
+    for(it=v.begin(); it!=v.end(); ++it){
+        //bitset<bit_len> bin(*it);
+        printBits(*it, bit_len);
+        cout <<  " ";
+        //cout << *it <<  " ";
+    }
+    cout << endl;
+}
+
+int main(int argc, char** argv)
+{
+    int n = 2;
+    if (argc>1){
+        n = atoi(argv[1]); 
+    }
+    vector<int> v = grayCode(n);
+    printVector(v, n);
+    return 0;
+}

From 7eaf50ec049d58b134143df5e8e87963da638266 Mon Sep 17 00:00:00 2001
From: shrekcodes <57681470+shrekcodes@users.noreply.github.com>
Date: Sun, 18 Oct 2020 15:50:00 +0530
Subject: [PATCH 111/203] Create #66-Plus_one.cpp

---
 ONLINE JUDGE/LeetCode/#66-Plus_one.cpp | 46 ++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#66-Plus_one.cpp

diff --git a/ONLINE JUDGE/LeetCode/#66-Plus_one.cpp b/ONLINE JUDGE/LeetCode/#66-Plus_one.cpp
new file mode 100644
index 0000000..0f0912f
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#66-Plus_one.cpp	
@@ -0,0 +1,46 @@
+* 
+* Given a non-negative number represented as an array of digits, plus one to the number.
+* 
+* The digits are stored such that the most significant digit is at the head of the list.
+*               
+**********************************************************************************/
+
+#include <iostream>
+#include <vector>
+using namespace std;
+
+vector<int> plusOne(vector<int> &digits) {
+    int carry=1;
+    vector <int> v;
+    while(digits.size()>0){
+        int x = digits.back();
+        digits.pop_back();
+        x = x + carry;
+        v.insert(v.begin(), x%10);
+        carry = x/10;
+    }
+    if (carry>0){
+        v.insert(v.begin(), carry);
+    }
+    return v;
+
+}
+
+void printVector(vector<int>& v)
+{
+    cout << "{ ";
+    for(int i=0; i<v.size(); i++){
+        cout << v[i] << " ";
+    }
+    cout << "} " << endl;
+}
+
+
+int main()
+{
+    int a[]={9,9,9};
+    vector<int> d(&a[0], &a[0]+sizeof(a)/sizeof(int));
+    vector<int> v = plusOne(d);
+    printVector(v);
+    return 0;
+}

From cabda4ce0174f68b20d898a53550ca5a116e94e7 Mon Sep 17 00:00:00 2001
From: shrekcodes <57681470+shrekcodes@users.noreply.github.com>
Date: Sun, 18 Oct 2020 15:51:45 +0530
Subject: [PATCH 112/203] Create #130-Surrounded-Reason.cpp

---
 .../LeetCode/#130-Surrounded-Reason.cpp       | 46 +++++++++++++++++++
 1 file changed, 46 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#130-Surrounded-Reason.cpp

diff --git a/ONLINE JUDGE/LeetCode/#130-Surrounded-Reason.cpp b/ONLINE JUDGE/LeetCode/#130-Surrounded-Reason.cpp
new file mode 100644
index 0000000..0f0912f
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#130-Surrounded-Reason.cpp	
@@ -0,0 +1,46 @@
+* 
+* Given a non-negative number represented as an array of digits, plus one to the number.
+* 
+* The digits are stored such that the most significant digit is at the head of the list.
+*               
+**********************************************************************************/
+
+#include <iostream>
+#include <vector>
+using namespace std;
+
+vector<int> plusOne(vector<int> &digits) {
+    int carry=1;
+    vector <int> v;
+    while(digits.size()>0){
+        int x = digits.back();
+        digits.pop_back();
+        x = x + carry;
+        v.insert(v.begin(), x%10);
+        carry = x/10;
+    }
+    if (carry>0){
+        v.insert(v.begin(), carry);
+    }
+    return v;
+
+}
+
+void printVector(vector<int>& v)
+{
+    cout << "{ ";
+    for(int i=0; i<v.size(); i++){
+        cout << v[i] << " ";
+    }
+    cout << "} " << endl;
+}
+
+
+int main()
+{
+    int a[]={9,9,9};
+    vector<int> d(&a[0], &a[0]+sizeof(a)/sizeof(int));
+    vector<int> v = plusOne(d);
+    printVector(v);
+    return 0;
+}

From e41d8bdb1909416a0aa037ff1dc0f89021df80fb Mon Sep 17 00:00:00 2001
From: Shreyash Royzada <65035990+ShreyashRoyzada@users.noreply.github.com>
Date: Tue, 20 Oct 2020 22:22:39 +0530
Subject: [PATCH 113/203] Create #7 Reverse Integer.cpp

---
 ONLINE JUDGE/LeetCode/#7 Reverse Integer.cpp | 43 ++++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#7 Reverse Integer.cpp

diff --git a/ONLINE JUDGE/LeetCode/#7 Reverse Integer.cpp b/ONLINE JUDGE/LeetCode/#7 Reverse Integer.cpp
new file mode 100644
index 0000000..d84ebcd
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#7 Reverse Integer.cpp	
@@ -0,0 +1,43 @@
+class Solution {
+public:
+    int reverse(long long int x) 
+{
+    long long int b=0,c=0;
+    long long int a;
+    vector<int> ar;
+        if(x<0)
+        {
+            a=(-x);
+        }
+        else
+        {
+            a=x;
+        }
+        for(int i=1;a>0;i++)
+        {
+            b=a%10;
+            ar.push_back(b);
+            a=a/10;
+        }
+        int k=ar.size();
+    for(int j=0;j<k;j++)
+    {
+       c=c+(ar.at(j)*pow(10,(k-j-1))); 
+        
+    }
+        if(c>=INT_MAX)
+        {
+            c=0;
+        }
+        else if(x<0)
+        {
+            c=(-c);
+        }
+        else
+        {
+            c=c;
+        }
+        return c;
+        
+}
+};

From d48b0925fe8bb9cbe787eaa3a5ac0dc866d7fd54 Mon Sep 17 00:00:00 2001
From: Shreyash Royzada <65035990+ShreyashRoyzada@users.noreply.github.com>
Date: Tue, 20 Oct 2020 22:23:54 +0530
Subject: [PATCH 114/203] Create #13 Roman to Integer.cpp

---
 .../LeetCode/#13 Roman to Integer.cpp         | 93 +++++++++++++++++++
 1 file changed, 93 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#13 Roman to Integer.cpp

diff --git a/ONLINE JUDGE/LeetCode/#13 Roman to Integer.cpp b/ONLINE JUDGE/LeetCode/#13 Roman to Integer.cpp
new file mode 100644
index 0000000..6368277
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#13 Roman to Integer.cpp	
@@ -0,0 +1,93 @@
+class Solution {
+public:
+    int romanToInt(string s) {
+        string rom=s;
+        int a=rom.size(),ans=0;
+        for(int i=0;i<a;i++)
+        {
+            {
+                if(rom.at(i)=='I')
+                {
+                ans=ans+1;
+                }
+            }
+            {
+                if(rom.at(i)=='V')
+                {
+                ans=ans+5;
+                }
+            }
+            {
+                if(rom.at(i)=='X')
+                {
+                ans=ans+10;
+                }
+            }
+            {
+                if(rom.at(i)=='L')
+                {
+                ans=ans+50;
+                }
+            }
+            {
+                if(rom.at(i)=='C')
+                {
+                ans=ans+100;
+                }
+            }
+            {
+                if(rom.at(i)=='D')
+                {
+                ans=ans+500;
+                }
+            }
+            {
+                if(rom.at(i)=='M')
+                {
+                ans=ans+1000;
+                }
+            }
+            if(i+1<a)
+            {
+                {
+                if((rom.at(i)=='I')&&(rom.at(i+1)=='V'))
+                {
+                    ans=ans-2;
+                }            
+                }
+                {
+                if((rom.at(i)=='I')&&(rom.at(i+1)=='X'))
+                {
+                    ans=ans-2;
+                }            
+                }
+                {
+                if((rom.at(i)=='X')&&(rom.at(i+1)=='L'))
+                {
+                    ans=ans-20;
+                }            
+                }
+                {
+                if((rom.at(i)=='X')&&(rom.at(i+1)=='C'))
+                {
+                    ans=ans-20;
+                }            
+                }
+                {
+                if((rom.at(i)=='C')&&(rom.at(i+1)=='D'))
+                {
+                    ans=ans-200;
+                }            
+                }
+                {
+                if((rom.at(i)=='C')&&(rom.at(i+1)=='M'))
+                {
+                    ans=ans-200;
+                }            
+                }
+            }
+            
+        }
+        return ans;
+    }
+};

From 9db89faf0a9b9e636aece3e7289f21ab6a1e3748 Mon Sep 17 00:00:00 2001
From: Shreyash Royzada <65035990+ShreyashRoyzada@users.noreply.github.com>
Date: Tue, 20 Oct 2020 22:26:28 +0530
Subject: [PATCH 115/203] Create #35 Search Insert Position.cpp

---
 .../LeetCode/#35 Search Insert Position.cpp   | 22 +++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#35 Search Insert Position.cpp

diff --git a/ONLINE JUDGE/LeetCode/#35 Search Insert Position.cpp b/ONLINE JUDGE/LeetCode/#35 Search Insert Position.cpp
new file mode 100644
index 0000000..f13f7ba
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#35 Search Insert Position.cpp	
@@ -0,0 +1,22 @@
+class Solution {
+public:
+    int searchInsert(vector<int>& nums, int target) 
+    {
+        vector<int> n=nums;
+        int t=target,ans;
+        for(int i=0;i<n.size();i++)
+        {
+            if(n.at(i)==t)
+            {
+                ans=i;
+                break;
+            }
+            if(n.at(i)>t)
+            {
+                ans=i;
+                break;
+            }
+        }
+        return ans;
+    }
+};

From 3e12138cdcee2d7b11768e07cab7c90f2e795df0 Mon Sep 17 00:00:00 2001
From: sohilmomin <sohilmomin711@gmail.com>
Date: Thu, 22 Oct 2020 10:17:39 +0530
Subject: [PATCH 116/203] added build_binary_tree_from_parentArray

---
 .../build_binary_tree_from_parentArray.cpp    | 45 +++++++++++++++++++
 1 file changed, 45 insertions(+)
 create mode 100644 18-Binary Tree/build_binary_tree_from_parentArray.cpp

diff --git a/18-Binary Tree/build_binary_tree_from_parentArray.cpp b/18-Binary Tree/build_binary_tree_from_parentArray.cpp
new file mode 100644
index 0000000..c640f2c
--- /dev/null
+++ b/18-Binary Tree/build_binary_tree_from_parentArray.cpp	
@@ -0,0 +1,45 @@
+//build binary tree from parent array
+
+#include<bits/stdc++.h>
+using namespace std;
+
+struct node{
+	int data;
+	struct node* left;
+	struct node* right;
+};
+
+struct node* makeTree(vector<int> a,int i,int n){
+	if(i<n){
+		if(a[i]==-1)
+			return NULL;
+		struct node* root = (node*)malloc(sizeof(node));
+		root->data=a[i];
+		root->left=makeTree(a,2*i+1,n);
+		root->right=makeTree(a,2*i+2,n);
+		return root;	
+	}
+	return NULL;
+}
+void inorder(struct node* root){
+	if(root==NULL){
+		return;
+	}
+	inorder(root->left);
+	cout<<root->data<<" ";
+	inorder(root->right);
+	return;
+}
+int main(){
+	int n;
+	cin>>n;
+	//1 2 3 -1 -1 4 5 -1 -1 -1 -1 6 7  [parent array]
+	vector<int> a(n);
+	for(int i=0;i<n;i++){
+		cin>>a[i];
+	}
+	struct node* root = makeTree(a,0,n);
+	inorder(root);
+	
+}
+

From c9deb9c8331fc2d25b2a4bca463f2f9f88ecccfa Mon Sep 17 00:00:00 2001
From: sohilmomin <sohilmomin711@gmail.com>
Date: Thu, 22 Oct 2020 11:21:02 +0530
Subject: [PATCH 117/203] added Algorithm

---
 18-Binary Tree/Largest_sum_subtree.cpp | 88 ++++++++++++++++++++++++++
 1 file changed, 88 insertions(+)
 create mode 100644 18-Binary Tree/Largest_sum_subtree.cpp

diff --git a/18-Binary Tree/Largest_sum_subtree.cpp b/18-Binary Tree/Largest_sum_subtree.cpp
new file mode 100644
index 0000000..e7da5ae
--- /dev/null
+++ b/18-Binary Tree/Largest_sum_subtree.cpp	
@@ -0,0 +1,88 @@
+//Tree representation 2
+#include<iostream>
+#include<bits/stdc++.h>
+#include<stdlib.h>
+using namespace std;
+//just one struct that will create Node using constracter function 
+struct node{
+	int data;
+	struct node* left;
+	struct node* right;
+	node(int data){
+			this->data=data;
+	left=right=NULL;
+	}
+};
+
+int max(int x,int y){
+	if(x>y)
+	return x;
+	return y;
+}
+//Largest sum subtree
+int LargestSubtree(struct node* root,int &maxSum){
+	if(root==NULL){
+		return 0;
+	}
+	int ls = LargestSubtree(root->left,maxSum);
+	int rs = LargestSubtree(root->right,maxSum);
+	int whole  = ls + rs + root->data;
+	if(whole > maxSum){
+		maxSum = whole;
+	}
+	else if(ls> maxSum){
+		maxSum  = ls ;
+	}
+	else if (rs> maxSum)
+		maxSum = rs;
+	return  root->data + rs + ls;
+}
+
+//just traversal function [utility function]
+void printInorder(struct node* root){
+	if(root==NULL){
+		return ;
+	}
+	printInorder(root->left);
+	cout<<root->data<<" ";
+	printInorder(root->right);
+}
+//driver program
+int main(){
+
+/*
+            1     
+          /   \
+        2       3
+      /  \     /  \
+     4    5    6    7
+    / \  / \  / \  / \ 
+   8  9 3   1 4  2 7  2
+       / \      /   \
+     -16 -17   -18  -19
+*/
+    node* root = new node(1); 
+    root->left = new node(2); 
+    root->right = new node(3); 
+    root->left->left = new node(4); 
+    root->left->right = new node(5); 
+    root->right->left = new node(6); 
+    root->right->right = new node(7); 
+    root->left->left->left = new node(8); 
+    root->left->left->right = new node(9); 
+    root->left->right->left = new node(3); 
+    root->left->right->right = new node(1); 
+    root->right->left->left = new node(4); 
+    root->right->left->right = new node(2); 
+    root->right->right->left = new node(7); 
+    root->right->right->right = new node(2); 
+    root->left->right->left->left = new node(-16); 
+    root->left->right->left->right = new node(-17); 
+    root->right->left->right->left = new node(-18); 
+    root->right->right->left->right = new node(-19);
+	cout<<"Inorder traversal of Binary Tree is  : \n"; 
+	printInorder(root);		  	//traversing Tree
+	int maxSum =INT_MIN;
+	int x = LargestSubtree(root,maxSum);
+	cout<<"\nSubtree with Largest Sum : "<<maxSum;
+}

From 7d590d9c0c0967ebf237927f95893e10478fa706 Mon Sep 17 00:00:00 2001
From: Rishab Kumar <33695234+potter1024@users.noreply.github.com>
Date: Thu, 22 Oct 2020 11:37:54 +0530
Subject: [PATCH 118/203] Create Merge Sort.cpp

---
 13- Linked Lists/Merge Sort.cpp | 40 +++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)
 create mode 100644 13- Linked Lists/Merge Sort.cpp

diff --git a/13- Linked Lists/Merge Sort.cpp b/13- Linked Lists/Merge Sort.cpp
new file mode 100644
index 0000000..d491f24
--- /dev/null
+++ b/13- Linked Lists/Merge Sort.cpp	
@@ -0,0 +1,40 @@
+node* split(node* head){
+    node* hare=head;
+    node* tortoise=head;
+    while(hare->next !=NULL && hare->next->next!=NULL){
+        hare=hare->next->next;
+        tortoise=tortoise->next;
+    }
+    if(hare->next==NULL){
+        node* r=tortoise->next;
+        tortoise->next=NULL;
+        return r;
+    }
+    else{
+        node* r=tortoise->next;
+        tortoise->next=NULL;
+        return r;
+    }
+}
+node* converge(node* head1,node* head2){
+    if(!head1){
+        return head2;
+    }
+    if(!head2){
+        return head1;
+    }
+    if(head1->data<=head2->data){
+        head1->next=converge(head1->next,head2);
+        return head1;
+    }
+    else{
+        head2->next=converge(head1,head2->next);
+        return head2;
+    }
+}
+node* mergeSort(node* head){
+    if(!head || head->next==NULL){
+        return head;
+    }
+    return converge(mergeSort(split(head)),mergeSort(head));
+}

From 34025fa3bd3521edb1f3f2809a41fb8df6f4bdce Mon Sep 17 00:00:00 2001
From: Rishab Kumar <33695234+potter1024@users.noreply.github.com>
Date: Thu, 22 Oct 2020 11:46:56 +0530
Subject: [PATCH 119/203] Create Fibonacci number in log(n)

---
 09- Number Theory/Fibonacci number in log(n) | 64 ++++++++++++++++++++
 1 file changed, 64 insertions(+)
 create mode 100644 09- Number Theory/Fibonacci number in log(n)

diff --git a/09- Number Theory/Fibonacci number in log(n) b/09- Number Theory/Fibonacci number in log(n)
new file mode 100644
index 0000000..e9f0ec6
--- /dev/null
+++ b/09- Number Theory/Fibonacci number in log(n)	
@@ -0,0 +1,64 @@
+struct mat
+{
+    ll a,b,c,d;
+};
+mat po(ll n)
+{
+    if(n==1)
+    {
+        mat in;
+        in.a=1;
+        in.b=1;
+        in.c=1;
+        in.d=0;
+        return in;
+    }
+    if(n==2)
+    {
+        mat in;
+        in.a=2;
+        in.b=1;
+        in.c=1;
+        in.d=1;
+        return in;
+    }
+    else
+    {
+        mat a=po(n/2);
+        mat b;
+        b.a=(a.a)*(a.a)+(a.b)*(a.c);
+        b.b=(a.a)*(a.b)+(a.b)*(a.d);
+        b.c=(a.a)*(a.c)+(a.c)*(a.d);
+        b.d=(a.b)*(a.c)+(a.d)*(a.d);
+        b.a%=M;
+        b.b%=M;
+        b.c%=M;
+        b.d%=M;
+        if(n%2==1)
+        {
+            mat c;
+            c.a=b.a+b.b;
+            c.b=b.a;
+            c.c=b.c+b.d;
+            c.d=b.c;
+            c.a%=M;
+            c.b%=M;
+            c.c%=M;
+            c.d%=M;
+            return c;
+        }
+        return b;
+    }
+}
+int main()
+{
+    she_taught_me_to_code
+
+    // freopen("input.txt","r",stdin);
+    // freopen("output.txt","w",stdout);
+
+    ll n;
+    cin>>n;
+    mat re=po(n);
+    cout<<re.c<<" ";
+}

From 49eeedd443eab1e14ace3d7bf595e6d43251de85 Mon Sep 17 00:00:00 2001
From: Rishab Kumar <33695234+potter1024@users.noreply.github.com>
Date: Thu, 22 Oct 2020 18:34:02 +0530
Subject: [PATCH 120/203] Update Fibonacci number in log(n)

---
 09- Number Theory/Fibonacci number in log(n) | 40 ++++++++++++++++----
 1 file changed, 32 insertions(+), 8 deletions(-)

diff --git a/09- Number Theory/Fibonacci number in log(n) b/09- Number Theory/Fibonacci number in log(n)
index e9f0ec6..a346995 100644
--- a/09- Number Theory/Fibonacci number in log(n)	
+++ b/09- Number Theory/Fibonacci number in log(n)	
@@ -1,8 +1,35 @@
+#include<bits/stdc++.h>
+using namespace std;
+#define sz(a)               ll((a).size())
+#define ll                  long long
+#define int                 ll
+#define pb                  push_back
+#define ld                  long double
+#define mp                  make_pair
+#define vi                  vector<ll>
+#define vii                  vector<pi>
+#define endl                "\n"
+#define ff                  first
+#define ss                  second
+#define all(c)              (c).begin(),(c).end()
+#define allr(c)             (c).rbegin(),(c).rend()
+#define input(a,n)          for(long long i=0;i<n;i++)cin>>a[i]
+#define output(a,n)         for(long long i=0;i<n;i++)cout<<a[i]<<" "
+#define inputt(a,n,m)       for(ll i=0;i<n;i++)for(ll j=0;j<m;j++)cin>>a[i][j]
+#define outputt(a,n,m)      for(ll i=0;i<n;i++){for(ll j=0;j<m;j++)cout<<a[i][j]<<" ";cout<<endl;}
+#define reset(a,n)          memset(a,n,sizeof(a))   // n can only be 0 or -1
+#define pi                  pair<ll,ll>
+#define inf                 LLONG_MAX
+#define N                   1000000
+#define minp                vector<ll>, greater<ll>
+#define M                   1000000007
+#define MM                  1000000009
+#define pie                 3.1415926535897932384626433832795
 struct mat
 {
     ll a,b,c,d;
 };
-mat po(ll n)
+mat po(ll n)        // matrix exponentiation for calculating fibonnaci number in log(n) time.
 {
     if(n==1)
     {
@@ -50,15 +77,12 @@ mat po(ll n)
         return b;
     }
 }
-int main()
+int32_t main()
 {
-    she_taught_me_to_code
-
-    // freopen("input.txt","r",stdin);
-    // freopen("output.txt","w",stdout);
 
     ll n;
     cin>>n;
-    mat re=po(n);
-    cout<<re.c<<" ";
+    mat re=po(n);       // calling the function
+    cout<<re.c<<endl;
+    return 0;
 }

From 95cb29987fa3ea0170bb6e7b6cffac01d71235fc Mon Sep 17 00:00:00 2001
From: Rishab Kumar <33695234+potter1024@users.noreply.github.com>
Date: Thu, 22 Oct 2020 18:36:34 +0530
Subject: [PATCH 121/203] Update Merge Sort.cpp

---
 13- Linked Lists/Merge Sort.cpp | 45 ++++++++++++++++++++++++++++++++-
 1 file changed, 44 insertions(+), 1 deletion(-)

diff --git a/13- Linked Lists/Merge Sort.cpp b/13- Linked Lists/Merge Sort.cpp
index d491f24..99552ff 100644
--- a/13- Linked Lists/Merge Sort.cpp	
+++ b/13- Linked Lists/Merge Sort.cpp	
@@ -1,3 +1,34 @@
+#include<bits/stdc++.h>
+using namespace std;
+struct node{
+    int data;
+    node* next;
+};
+void insert(int data,node** head){
+    if(*head==NULL){
+        node* n=new node;
+        n->data=data;
+        n->next=NULL;
+        *head=n;
+        return;
+    }
+    node* current=*head;
+    while(current->next!=NULL){
+        current=current->next;
+    }
+    node* n=new node;
+    n->data=data;
+    n->next=NULL;
+    current->next=n;
+}
+void print(node* head){
+    node* current=head;
+    while(current!=NULL){
+        cout<<current->data<<" ";
+        current=current->next;
+    }
+    cout<<endl;
+}
 node* split(node* head){
     node* hare=head;
     node* tortoise=head;
@@ -36,5 +67,17 @@ node* mergeSort(node* head){
     if(!head || head->next==NULL){
         return head;
     }
-    return converge(mergeSort(split(head)),mergeSort(head));
+    node* node1=head;
+    node* node2=split(head);
+    return converge(mergeSort(node1),mergeSort(split(head)));
+}
+int main(){
+    node* head=NULL;
+    insert(2,&head);
+    insert(4,&head);
+    insert(3,&head);
+    insert(1,&head);
+    print(head);
+    head=mergeSort(head);
+    print(head);
 }

From 01cc71f2c22ed025242fc8be5a53b6f5b2eb4cc9 Mon Sep 17 00:00:00 2001
From: Yasasvi Peruvemba <44848793+YasasviPeruvemba@users.noreply.github.com>
Date: Thu, 22 Oct 2020 20:57:29 +0530
Subject: [PATCH 122/203] Create QuineMcCluskey.cpp

The implementation of the QuineMcClusky Algorithm to reduce the minterms for a boolean expression.
---
 Miscellaneous/QuineMcCluskey.cpp | 442 +++++++++++++++++++++++++++++++
 1 file changed, 442 insertions(+)
 create mode 100644 Miscellaneous/QuineMcCluskey.cpp

diff --git a/Miscellaneous/QuineMcCluskey.cpp b/Miscellaneous/QuineMcCluskey.cpp
new file mode 100644
index 0000000..f105666
--- /dev/null
+++ b/Miscellaneous/QuineMcCluskey.cpp
@@ -0,0 +1,442 @@
+#include <bits/stdc++.h>
+using namespace std;
+
+//Helper class for utilities
+class Helper{
+public:
+	//Converting Integer to String
+	string intToBin(int val){
+		int mod;
+		string bin="";
+		while(val!=0){
+			mod = val%2;
+			if(mod){
+				bin = bin + "1";
+			}
+			else bin = bin + "0";
+			val/=2;
+		}
+		reverse(bin.begin(),bin.end());
+		return bin;
+	}
+
+	//Padding zeros to accomodate all variables
+	string pad(string bin, int no_var){
+		int m = no_var - bin.size();
+		for(int i=0;i<m;i++){
+			bin = "0" + bin;
+		}
+		return bin;
+	}
+
+	//Getting number of 1's in a string
+	int getOnes(string a){
+		int cnt=0;
+		for(int i=0;i<a.size();i++){
+			if(a[i]=='1'){cnt++;}
+		}
+		return cnt;
+	}
+
+	//Checking if pair is grey code or not
+	bool compare(string a, string b){
+		int cnt=0;
+		for(int i=0;i<a.size();i++){
+			if(a[i]!=b[i]){cnt++;}
+		}
+		if(cnt==1){return true;}
+		return false;
+	}
+
+	//Reducing the differing location with don't care (*)
+	string reduce(string a, string b){
+		string x="";
+		for(int i=0;i<a.size();i++){
+			if(a[i]!=b[i]){x = x + "*";}
+			else x = x + a[i];
+		}
+		return x;
+	}
+
+	//Checking if the Table is empty
+	bool isEmpty(vector < vector <string> > &table){
+		for(int i=0;i<table.size();i++){
+			if(table[i].size()!=0){
+				return false;
+			}
+		}
+		return true;
+	}
+
+	//Converting string of 1's and 0's to A's & B's
+	string expression(string a){
+		string x="";
+		char c;
+		for(int i=0;i<a.size();i++){
+			if(a[i]=='0'){
+				c = 65 + i;
+				x = x + c;
+				x = x + '\'';
+			}
+			else if(a[i]=='1'){
+				c = 65 + i;
+				x = x + c;
+			}
+		}
+		return x;
+	}
+
+	//Checking if a minterm is satisfied by the Prime Implicant
+	bool primeImpIncludes(string imp, string minterm){
+		for(int i=0;i<minterm.size();i++){
+			if(imp[i]=='*'){continue;}
+			else{
+				if(imp[i]!=minterm[i]){
+					return false;
+				}
+			}
+		}
+		return true;
+	}
+
+	//Returns number of variables in a Petrick method combination
+	int getNumVar(vector <int> comb, vector <string> primeImp){
+		int cnt=0;
+		for(int i=0;i<comb.size();i++){
+			int implicant = comb[i];
+			for(int j=0;j<primeImp[implicant].size();j++){
+				if(primeImp[implicant][j]!='*'){
+					cnt++;
+				}
+			}
+		}
+		return cnt;
+	}
+
+};
+
+//Class to solve the boolean expression using Quine-McCluskey followed by Petrick's Method
+class QMSolver{
+private:
+	Helper helper;
+	vector <int> minInt; //Minterms as Integers
+	vector <string> minBin; //Minterms in Binary representation
+	int no_var;
+	int no_minterms;
+	vector < vector <string> > table; 
+	vector <string> primeImp;
+	vector <string> essPrimeImp;
+	vector < vector <int> > finalImp;
+	vector <int> afterRemImp;
+	vector <int> afterRemMinterm;
+
+public:
+
+	bool init(){
+		cout<<"Enter number of variables (1-20) : ";
+		cin>>no_var;
+		while(no_var > 20 || no_var < 1){
+			cout<<"\nEnter valid number of variables!\n\n";
+			cout<<"Enter number of variables (1-20) : ";
+			cin>>no_var;
+		}
+
+		string minterm,mt;
+		bool flag = false;
+		long long int range = pow(2,no_var)-1;
+		cout<<"Enter minterms (Range from 0-"<<range<<") separated by commas:\n";
+		cin>>minterm;
+		//Splitting the minterms
+		stringstream checker(minterm);
+		while(getline(checker,mt,',')){
+			int number = atoi(mt.data());
+			if(number > range){
+				cout<<"\nError, minterm out of range!\n\n";
+				return false;
+			}
+			if(find(minInt.begin(),minInt.end(),number)!=minInt.end()){cout<<"\nDuplicate value of minterm "<<number<<"!\n\n"; return false;}
+			minInt.push_back(number);
+			minBin.push_back(helper.pad(helper.intToBin(number),no_var));
+			//cout<<solver.pad(solver.bin(number),n)<<endl;
+		}
+		sort(minBin.begin(),minBin.end());
+		sort(minInt.begin(),minInt.end());
+		no_minterms = minInt.size();
+
+		table = vector< vector<string> >(no_var+1);
+		return true;
+
+	}
+
+	//Creating Table based number of one's
+	void createTable(){
+		for(int i=0;i<no_minterms;i++){
+			int x = helper.getOnes(minBin[i]);
+			table[x].push_back(minBin[i]);
+		}
+	}
+
+	//Matching pairs between every consequent rows in the table and condensing them into a new table
+	vector < vector <string> > matchPairs(vector < vector <string> > &table, vector <string> &primeImp){
+		bool checked[table.size()][no_minterms]={false};
+		vector < vector<string> > newTable(table.size()-1);
+
+		for(int i=0;i<table.size()-1;i++){
+			for(int j=0;j<table[i].size();j++){
+				for(int k=0;k<table[i+1].size();k++){
+					if(helper.compare(table[i][j],table[i+1][k])){
+						checked[i][j] = true;
+						checked[i+1][k] = true;
+						newTable[i].push_back(helper.reduce(table[i][j],table[i+1][k]));
+					}
+				}
+			}
+		}
+
+		//Adding the implicants that couldn't be condensed
+		for(int i=0;i<table.size();i++){
+			for(int j=0;j<table[i].size();j++){
+				if(!checked[i][j]){
+					if(find(primeImp.begin(),primeImp.end(),table[i][j])!=primeImp.end()){continue;}
+					primeImp.push_back(table[i][j]);
+				}
+			}
+		}
+
+		return newTable;
+	}
+
+	//Getting the Prime Implicants
+	void getPrimeImp(){
+		createTable();
+
+		while(!helper.isEmpty(table)){
+			table = matchPairs(table,primeImp);
+		}
+
+		sort(primeImp.begin(),primeImp.end());
+
+		cout<<"\nThe Prime Implicants are :\n\n";
+		for(int i=0;i<primeImp.size();i++){
+			cout<<helper.expression(primeImp[i])<<endl;
+		}
+		cout<<endl;
+	}
+
+	void finalMinimise(){
+		//Making the table to find cover for prime Implicants
+		int primeImpTable[primeImp.size()][no_minterms];
+		int counter[no_minterms];
+		memset(primeImpTable,0,sizeof(primeImpTable));
+		memset(counter,0,sizeof(counter));
+
+		for(int i=0;i<primeImp.size();i++){
+			for(int j=0;j<no_minterms;j++){
+				if(helper.primeImpIncludes(primeImp[i],minBin[j])){
+					primeImpTable[i][j] = 1;
+					counter[j]++;
+				}
+			}
+		}
+
+		//Pushing Essential Prime Implicants first
+		for(int j=0;j<no_minterms;j++){
+			if(counter[j]==1){
+				for(int i=0;i<primeImp.size();i++){
+					if(primeImpTable[i][j]==1){
+						if(find(essPrimeImp.begin(),essPrimeImp.end(),primeImp[i])!=essPrimeImp.end()){continue;}
+						essPrimeImp.push_back(primeImp[i]);
+					}
+					else{
+						afterRemImp.push_back(i);
+					}
+				}
+			}
+		}
+
+		//Removing Minterms
+		set <int> remMinterm;
+		for(int i=0;i<essPrimeImp.size();i++){
+			for(int j=0;j<no_minterms;j++){
+				if(helper.primeImpIncludes(essPrimeImp[i],minBin[j])){
+					remMinterm.insert(j);
+				}	
+			}
+		}
+
+		if(essPrimeImp.size()==0){
+			cout<<"There are no essential prime implicants!\n\n";
+			for(int i=0;i<primeImp.size();i++){
+				afterRemImp.push_back(i);
+			}
+
+		}
+		else{
+			cout<<"The Essential Prime Implicants are :\n\n";
+			for(int i=0;i<essPrimeImp.size();i++){
+				cout<<helper.expression(essPrimeImp[i])<<"\n";	
+			}
+		}
+
+		for(int i=0;i<no_minterms;i++){
+			if(find(remMinterm.begin(),remMinterm.end(),i)!=remMinterm.end()){
+				continue;
+			}
+			else{
+				afterRemMinterm.push_back(i);
+			}
+		}
+
+		int afterRemImpTable[afterRemImp.size()][afterRemMinterm.size()];
+		memset(afterRemImpTable,0,sizeof(afterRemImpTable));
+
+		//Building the table again
+		for(int i=0;i<afterRemImp.size();i++){
+			for(int j=0;j<afterRemMinterm.size();j++){
+				if(helper.primeImpIncludes(primeImp[afterRemImp[i]],minBin[afterRemMinterm[j]])){
+					afterRemImpTable[i][j] = 1;
+				}
+			}
+		}
+
+		//Using Petrick's Method on the remaining Minterms and Implicants
+		vector < vector <int> > petrick;
+		for(int j=0;j<afterRemMinterm.size();j++){
+			vector <int> temp;
+			for(int i=0;i<afterRemImp.size();i++){
+				if(afterRemImpTable[i][j]){
+					temp.push_back(afterRemImp[i]);
+				}
+			}
+			if(find(petrick.begin(),petrick.end(),temp)!=petrick.end()){
+				continue;
+			}
+			petrick.push_back(temp);
+		}
+		sort(petrick.begin(),petrick.end());
+
+		//Getting all combinations
+		vector < vector <int> > possComb;
+		vector <int> product;
+		getAllComb(petrick,0,product,possComb);
+		int min=INT_MAX;
+
+		//Finding the minimum no of terms
+		for(int i=0;i<possComb.size();i++){
+			int x = possComb[i].size();
+			if(x < min){min = x;}
+		}
+
+		//Combination with minimum terms
+		vector < vector <int> > miniComb;
+		for(int i=0;i<possComb.size();i++){
+			if(possComb[i].size()==min){
+				// if(find(miniComb.begin(),miniComb.end(),possComb[i])!=miniComb.end()){continue;}
+				miniComb.push_back(possComb[i]);
+			}
+		}
+
+		min=INT_MAX;
+		for(int i=0;i<miniComb.size();i++){
+			int x = helper.getNumVar(miniComb[i],primeImp);
+			if(x < min){ min = x;}
+		} 
+
+		for(int i=0;i<miniComb.size();i++){
+			int x = helper.getNumVar(miniComb[i],primeImp);
+			if(x == min){
+				if(find(finalImp.begin(),finalImp.end(),miniComb[i])!=finalImp.end()){continue;}
+				finalImp.push_back(miniComb[i]);
+			}
+		} 
+
+	}
+
+	void getAllComb(vector < vector <int> > &petrick, int minT, vector <int> &product, vector < vector <int> > &possComb){
+		if(minT == petrick.size()){
+			vector <int> temp = product;
+			sort(temp.begin(),temp.end());
+			if(find(possComb.begin(),possComb.end(),temp)!=possComb.end()){return;}
+			possComb.push_back(temp);
+			return;
+		}
+		else{
+			for(int i=0;i<petrick[minT].size();i++){
+				int x = petrick[minT][i];
+				bool flag=true;
+				if(find(product.begin(),product.end(),x)!=product.end()){flag = false;}
+				if(flag){product.push_back(x);}
+				//recursing to get all possible combinations
+				getAllComb(petrick,minT+1,product,possComb);
+				if(flag){
+					product.erase(remove(product.begin(), product.end(), x), product.end());
+				}
+			}
+		}
+	}
+
+	void result(){
+		string ess="";
+		for(int i=0;i<essPrimeImp.size();i++){
+			ess = ess + helper.expression(essPrimeImp[i]) + " + ";
+		}
+		cout<<"\nThe possible canonical forms is/are :\n\n";
+		for(int i=0;i<finalImp.size();i++){
+			cout<<i+1<<". ";
+			string s = ess;
+			for(int j=0;j<finalImp[i].size();j++){
+				if(find(essPrimeImp.begin(),essPrimeImp.end(),primeImp[finalImp[i][j]])!=essPrimeImp.end()){continue;}
+				s = s + helper.expression(primeImp[finalImp[i][j]]) + " + ";	
+			}
+			s = s.erase(s.size()-3,2);
+			cout<<s<<endl;
+		}
+	}
+
+	void clear(){
+		minInt.clear();
+		minBin.clear(); 
+		table.clear(); 
+		primeImp.clear();
+		finalImp.clear();
+		afterRemImp.clear();
+		afterRemMinterm.clear();
+		essPrimeImp.clear();
+	}
+
+};
+
+int main(){
+	QMSolver solver;
+	char c='y';
+	while(c=='y'){
+		bool flg = solver.init();
+		while(!flg){
+			solver.clear();
+			flg = solver.init();
+		}
+		solver.getPrimeImp();
+		solver.finalMinimise();
+		solver.result();
+		solver.clear();
+		cout<<"\n\nDo you want to enter another expression? (y/n) : ";
+		cin>>c;
+	}
+	return 0;
+}
+
+/*
+
+test 1
+number of variables - 4
+minterms - 0,1,3,7,8,9,11,15
+
+test 2
+number of variables - 4
+minterms - 0,1,2,5,6,7,8,9,10,14
+
+test 3
+number of variables - 3
+minterms - 0,1,2,5,6,7
+
+*/

From cab7ab84bacd10b62a410eb6b995f07f3dcbbcfe Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Fri, 23 Oct 2020 21:23:18 +0530
Subject: [PATCH 123/203] Update README.md

---
 README.md | 17 +----------------
 1 file changed, 1 insertion(+), 16 deletions(-)

diff --git a/README.md b/README.md
index c1f2840..056e926 100644
--- a/README.md
+++ b/README.md
@@ -20,24 +20,9 @@ The Data Structure is the :heart: of Computer Science and Algorithms are the ste
 Some Most Comman Data Structure are like Array, Queue, Stack, Tree, Hash, Heap etc. Mastering these Data Structure will help you to solve many problems while you are doing competitive Programming or sitting for the Tech Interview. 
 
 
-However If You think that you have some great Resources and you love to contribute you can directly create a Pull Request. So Every PR must be check and pass test, and successful debug.
-
- ## Pull Request Instructions
- 
- * Instead of Creating a new Branch. Fork the Repo and Update Your contribution to the related files or Repo.
- * Try to add the Algorithm or Program in files respectively.
- * You can add new content only **Related to C++ Programming** 
- * Create a PR with subjective Title. This will help me to organize the content in better way.
- * Try to Update the `.gitignore` if you're adding different formats of content.
- * Create a PR :bowtie:
+However If You think that you have some great Resources and you love to contribute you can directly create a Pull Request [Check PR Instructions)](https://github.com/codewithdev/C-plus-plus-Algorithms/blob/master/CONTRIBUTING.md). So Every PR must be check and pass test, and successful debug.
  
-## _Resources_
-
-* [Geeks For Geeks](https://www.geeksforgeeks.org)
-
-* [Yang Shun Interview Material](https://yangshun.github.io/tech-interview-handbook/)
 
-* [Learn CPP Tutorials for Basics](https://www.learncpp.com)
  
  
  

From 4c3a10c9b6a5fd48b2ea96f39f625f027d5e7feb Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Fri, 23 Oct 2020 21:23:35 +0530
Subject: [PATCH 124/203] Update README.md

---
 README.md | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 056e926..9f9d40d 100644
--- a/README.md
+++ b/README.md
@@ -20,8 +20,7 @@ The Data Structure is the :heart: of Computer Science and Algorithms are the ste
 Some Most Comman Data Structure are like Array, Queue, Stack, Tree, Hash, Heap etc. Mastering these Data Structure will help you to solve many problems while you are doing competitive Programming or sitting for the Tech Interview. 
 
 
-However If You think that you have some great Resources and you love to contribute you can directly create a Pull Request [Check PR Instructions)](https://github.com/codewithdev/C-plus-plus-Algorithms/blob/master/CONTRIBUTING.md). So Every PR must be check and pass test, and successful debug.
- 
+However If You think that you have some great Resources and you love to contribute you can directly create a Pull Request [Check PR Instructions)](https://github.com/codewithdev/C-plus-plus-Algorithms/blob/master/CONTRIBUTING.md).
 
  
  

From 73e802bbcefcc759987ef08cc9d054a3f0855ba4 Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Sat, 24 Oct 2020 14:10:26 +0530
Subject: [PATCH 125/203] Create #23-Merge K Sorted Lists.cpp

---
 .../LeetCode/#23-Merge K Sorted Lists.cpp     | 42 +++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#23-Merge K Sorted Lists.cpp

diff --git a/ONLINE JUDGE/LeetCode/#23-Merge K Sorted Lists.cpp b/ONLINE JUDGE/LeetCode/#23-Merge K Sorted Lists.cpp
new file mode 100644
index 0000000..bbf636d
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#23-Merge K Sorted Lists.cpp	
@@ -0,0 +1,42 @@
+/**
+ * Definition for singly-linked list.
+ * struct ListNode {
+ *     int val;
+ *     ListNode *next;
+ *     ListNode() : val(0), next(nullptr) {}
+ *     ListNode(int x) : val(x), next(nullptr) {}
+ *     ListNode(int x, ListNode *next) : val(x), next(next) {}
+ * };
+ */
+struct compare {
+    bool operator()(
+        struct ListNode* a, struct ListNode* b)
+    {
+        return a->val > b->val;
+    }
+};
+class Solution {
+public:
+    ListNode* mergeKLists(vector<ListNode*>& arr) {
+    priority_queue<ListNode*,vector<ListNode*>,compare>pq;
+    int k= arr.size();
+    for(int i=0;i<k;i++)
+        if(arr[i]!=NULL)
+            pq.push(arr[i]);
+            
+        if(pq.empty())
+            return NULL;
+      ListNode dummy=ListNode(0);
+      ListNode*last= &dummy;
+      while(!pq.empty()){
+          ListNode*curr= pq.top();
+          pq.pop();
+          last->next= curr;
+          last= last->next;
+          
+          if(curr->next!=NULL)
+              pq.push(curr->next);
+      }
+    return dummy.next;
+     }
+};

From df29edbceb828f6eedec108978ce8903fe5641d5 Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Sat, 24 Oct 2020 14:10:58 +0530
Subject: [PATCH 126/203] Rename #23-Merge K Sorted Lists.cpp to
 #23-Merge-K-Sorted-Lists.cpp

---
 ...{#23-Merge K Sorted Lists.cpp => #23-Merge-K-Sorted-Lists.cpp} | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename ONLINE JUDGE/LeetCode/{#23-Merge K Sorted Lists.cpp => #23-Merge-K-Sorted-Lists.cpp} (100%)

diff --git a/ONLINE JUDGE/LeetCode/#23-Merge K Sorted Lists.cpp b/ONLINE JUDGE/LeetCode/#23-Merge-K-Sorted-Lists.cpp
similarity index 100%
rename from ONLINE JUDGE/LeetCode/#23-Merge K Sorted Lists.cpp
rename to ONLINE JUDGE/LeetCode/#23-Merge-K-Sorted-Lists.cpp

From da9e6d655d8d0fe21c2bcb4e06bcd2289c905bd6 Mon Sep 17 00:00:00 2001
From: kross9924 <47144465+kross9924@users.noreply.github.com>
Date: Sat, 24 Oct 2020 10:31:14 +0000
Subject: [PATCH 127/203] Create #1463-Cherry_Pickup_2.cpp

---
 .../LeetCode/#1463-Cherry_Pickup_2.cpp        | 24 +++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#1463-Cherry_Pickup_2.cpp

diff --git a/ONLINE JUDGE/LeetCode/#1463-Cherry_Pickup_2.cpp b/ONLINE JUDGE/LeetCode/#1463-Cherry_Pickup_2.cpp
new file mode 100644
index 0000000..7571b11
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#1463-Cherry_Pickup_2.cpp	
@@ -0,0 +1,24 @@
+class Solution {
+public:
+    int cherryPickup(vector<vector<int>>& grid) {
+        int m = grid.size();
+        int n = grid[0].size();
+        int f[m][n][n];
+        int res = 0;
+        memset(f, -1, sizeof(f));
+        f[0][0][n - 1] = grid[0][0] + grid[0][n-1];
+        for (int i = 1; i < m; i++)
+            for (int j = 0; j < n; j++)
+                for (int k = 0; k < n; k++) {
+                    int value = (j == k) ? grid[i][j] : grid[i][j] + grid[i][k];
+                    for (int col1 = j-1; col1 <= j+1; col1++)
+                        for (int col2 = k-1; col2 <= k+1; col2++) {
+							if (col1 >= 0 && col1 < n && col2 >= 0 && col2 < n && f[i-1][col1][col2] >= 0) {
+                                f[i][j][k] = max(f[i][j][k], f[i - 1][col1][col2] + value);
+                                if (i == m - 1) res = max(res, f[i][j][k]);
+                            }
+                        }
+                }
+        return res;
+    }
+};

From 492e48225367407591a1b9cec727f0b971398a1e Mon Sep 17 00:00:00 2001
From: Fernando Lincoln <lincolncpp@usp.br>
Date: Mon, 26 Oct 2020 17:39:47 -0300
Subject: [PATCH 128/203] Added Lyndon Factorization

---
 String/lyndon_factorization.cpp | 42 +++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 String/lyndon_factorization.cpp

diff --git a/String/lyndon_factorization.cpp b/String/lyndon_factorization.cpp
new file mode 100644
index 0000000..27eaf28
--- /dev/null
+++ b/String/lyndon_factorization.cpp
@@ -0,0 +1,42 @@
+#include <bits/stdc++.h>
+
+using namespace std;
+
+// Duval algorithm
+// Time complexity O(N)
+// Memory complexity O(1)
+vector<string> duval(string s){
+    vector<string>res;
+
+    int n = (int)s.size();
+    int i = 0; // s1 => [0...i-1] processed
+    int j = 0; // s2 => pre-simple string
+    int k = 1; // s3 => [k...n] unprocessed
+    while(i < n){
+        while (k < n && s[j] <= s[k]){
+            if (s[j] == s[k]) j++;
+            else j = i; // new simple created
+            k++;
+        }
+
+        // getting all simple string from s2
+        while(i <= j){
+            res.push_back(s.substr(i, k-j));
+            i += k-j;
+        }
+        j = i;
+        k = i+1;
+    }
+
+    return res;
+}
+
+
+int main(){
+
+    string s = "aababbaaab";
+    for(string &t:duval(s))
+        cout << t << endl;
+
+    return 0;
+}

From 767ad59e2512b6f421014eb9c1a3108ebd9382f2 Mon Sep 17 00:00:00 2001
From: Devansh Markan <500069794@stu.upes.ac.in>
Date: Thu, 29 Oct 2020 09:58:28 +0530
Subject: [PATCH 129/203] Added HackerRank solution of "Cpp exception handling"

---
 .../Hackerrank/#29-Cpp exception handling.cpp | 36 +++++++++++++++++++
 1 file changed, 36 insertions(+)
 create mode 100644 ONLINE JUDGE/Hackerrank/#29-Cpp exception handling.cpp

diff --git a/ONLINE JUDGE/Hackerrank/#29-Cpp exception handling.cpp b/ONLINE JUDGE/Hackerrank/#29-Cpp exception handling.cpp
new file mode 100644
index 0000000..4fd43cb
--- /dev/null
+++ b/ONLINE JUDGE/Hackerrank/#29-Cpp exception handling.cpp	
@@ -0,0 +1,36 @@
+#include <iostream>
+#include <stdexcept>
+
+using namespace std;
+
+int largest_proper_divisor(int n) {
+    if (n == 0) {
+        throw invalid_argument("largest proper divisor is not defined for n=0");
+    }
+    if (n == 1) {
+        throw invalid_argument("largest proper divisor is not defined for n=1");
+    }
+    for (int i = n/2; i >= 1; --i) {
+        if (n % i == 0) {
+            return i;
+        }
+    }
+    return -1; // will never happen
+}
+void process_input(int n) {
+    try {
+        int d = largest_proper_divisor(n);
+        cout << "result=" << d << endl;        
+    }
+    catch(invalid_argument e){
+        cout << e.what() << endl;
+    }
+    cout << "returning control flow to caller" << endl;
+}
+
+int main() {
+    int n;
+    cin >> n;
+    process_input(n);
+    return 0;
+}

From 01cfc2fab5f9e508cab6412cf62635d9c646cc70 Mon Sep 17 00:00:00 2001
From: shrekcodes <57681470+shrekcodes@users.noreply.github.com>
Date: Sat, 31 Oct 2020 00:37:46 +0530
Subject: [PATCH 130/203] Create #84-Largest_area_Histogram.cpp

---
 .../LeetCode/#84-Largest_area_Histogram.cpp   | 31 +++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#84-Largest_area_Histogram.cpp

diff --git a/ONLINE JUDGE/LeetCode/#84-Largest_area_Histogram.cpp b/ONLINE JUDGE/LeetCode/#84-Largest_area_Histogram.cpp
new file mode 100644
index 0000000..6ae1a90
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#84-Largest_area_Histogram.cpp	
@@ -0,0 +1,31 @@
+//https://leetcode.com/problems/largest-rectangle-in-histogram/
+
+class Solution {
+public:
+    int largestRectangleArea(vector<int>& heights) {
+        stack<int>s;
+        int area_with_top=0;
+        int area=0;
+        int i=0;
+        int n=heights.size();
+        while(i<n){
+            if(s.empty() || heights[s.top()]<=heights[i]){
+                s.push(i++);
+            }
+            else{
+                int tp=s.top();
+                s.pop();
+                area_with_top=heights[tp]*(s.empty()?i:i-s.top()-1);
+                if(area<area_with_top)
+                    area=area_with_top;
+            }
+        }
+        while(!s.empty()){
+            int tp=s.top();
+            s.pop();
+            area_with_top=heights[tp]*(s.empty()?i:i-s.top()-1);
+            area=max(area,area_with_top);
+        }
+        return area;
+    }
+};

From c4668bffedb2e17b691e8c56618129c3226d998c Mon Sep 17 00:00:00 2001
From: shrekcodes <57681470+shrekcodes@users.noreply.github.com>
Date: Sat, 31 Oct 2020 00:40:44 +0530
Subject: [PATCH 131/203] Create #41- First_missing_positive.cpp

---
 #41- First_missing_positive.cpp | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
 create mode 100644 #41- First_missing_positive.cpp

diff --git a/#41- First_missing_positive.cpp b/#41- First_missing_positive.cpp
new file mode 100644
index 0000000..391fdb1
--- /dev/null
+++ b/#41- First_missing_positive.cpp	
@@ -0,0 +1,18 @@
+class Solution {
+public:
+    int firstMissingPositive(vector<int>& nums) {
+        int n = nums.size();
+        vector<bool> nums_map(n+1);
+        for (int i = 0; i < n; i++) {
+            if(nums[i]<=n && nums[i]>0) { 
+                nums_map[nums[i]] = true;
+            }
+        }
+        for (int i=0; i<n; i++) {
+            i = i+1;
+            if (!nums_map[i]) 
+                return i; 
+        }
+        return n+1;
+    }
+};

From ebe59b07d717902deccc0f43424eacddaf3f1ed1 Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Sun, 1 Nov 2020 01:07:16 +0530
Subject: [PATCH 132/203] Update CONTRIBUTING.md

---
 CONTRIBUTING.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index fbbf18d..c4beecb 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1,4 +1,4 @@
-# Welcome to Hacktoberfest!
+
 
 Please Read the Contribution Guidelines before making Pull Request
 

From 08d4d62eb43609909cb9ae9d0fbcfbb55489c292 Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Sun, 1 Nov 2020 01:28:16 +0530
Subject: [PATCH 133/203] Update README.md

---
 README.md | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 9f9d40d..39e3826 100644
--- a/README.md
+++ b/README.md
@@ -25,4 +25,7 @@ However If You think that you have some great Resources and you love to contribu
  
  
  
- # Read Contributing.md for More Info
+ # HACKTOBERFEST STATS
+
+***_Congratulations!🎉 You Made it! _***
+I would like to thank all the Contributor who have participated in Hacktoberfest By DigitalOcean and Successfully contributed to **C-plus-plus-Alogrithms** Repository.Whether it was your first time in the Open Source or experience, Always remember _Every Expert was once a Beginner_.

From aa7827d1593609a21fafedec692c2408bb05bdbe Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Sun, 1 Nov 2020 01:28:44 +0530
Subject: [PATCH 134/203] Update README.md

---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 39e3826..e0d8f8c 100644
--- a/README.md
+++ b/README.md
@@ -27,5 +27,5 @@ However If You think that you have some great Resources and you love to contribu
  
  # HACKTOBERFEST STATS
 
-***_Congratulations!🎉 You Made it! _***
+***_Congratulations!🎉 You Made it!_***
 I would like to thank all the Contributor who have participated in Hacktoberfest By DigitalOcean and Successfully contributed to **C-plus-plus-Alogrithms** Repository.Whether it was your first time in the Open Source or experience, Always remember _Every Expert was once a Beginner_.

From 114b727710ca598aadad471e50c06f7114db7dcf Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Sun, 1 Nov 2020 01:29:21 +0530
Subject: [PATCH 135/203] Update README.md

---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index e0d8f8c..e17e15b 100644
--- a/README.md
+++ b/README.md
@@ -28,4 +28,4 @@ However If You think that you have some great Resources and you love to contribu
  # HACKTOBERFEST STATS
 
 ***_Congratulations!🎉 You Made it!_***
-I would like to thank all the Contributor who have participated in Hacktoberfest By DigitalOcean and Successfully contributed to **C-plus-plus-Alogrithms** Repository.Whether it was your first time in the Open Source or experience, Always remember _Every Expert was once a Beginner_.
+I would like to thank all the Contributor who have participated in Hacktoberfest this year By DigitalOcean and Successfully contributed to **C-plus-plus-Alogrithms** Repository.Whether it was your first time in the Open Source or experience, Always remember _Every Expert was once a Beginner_.

From 725760fef81b0ea6af8bd525c6d7c9a12e59f62a Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Sun, 1 Nov 2020 01:29:48 +0530
Subject: [PATCH 136/203] Update README.md

---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index e17e15b..58eef1c 100644
--- a/README.md
+++ b/README.md
@@ -28,4 +28,4 @@ However If You think that you have some great Resources and you love to contribu
  # HACKTOBERFEST STATS
 
 ***_Congratulations!🎉 You Made it!_***
-I would like to thank all the Contributor who have participated in Hacktoberfest this year By DigitalOcean and Successfully contributed to **C-plus-plus-Alogrithms** Repository.Whether it was your first time in the Open Source or experience, Always remember _Every Expert was once a Beginner_.
+I would like to thank all the Contributor who have participated in Hacktoberfest this year By DigitalOcean and Successfully contributed to **C-plus-plus-Alogrithms** Repository. Whether it was your first time in the Open Source or having experience, Always remember _Every Expert was once a Beginner_.

From 53a7498c8c0a58616aa88259f403b72332f7158e Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Sun, 1 Nov 2020 21:52:14 +0530
Subject: [PATCH 137/203] Create #918-Maximum_Sum_Circular_Subarray.cpp

---
 .../#918-Maximum_Sum_Circular_Subarray.cpp    | 23 +++++++++++++++++++
 1 file changed, 23 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#918-Maximum_Sum_Circular_Subarray.cpp

diff --git a/ONLINE JUDGE/LeetCode/#918-Maximum_Sum_Circular_Subarray.cpp b/ONLINE JUDGE/LeetCode/#918-Maximum_Sum_Circular_Subarray.cpp
new file mode 100644
index 0000000..6cab330
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#918-Maximum_Sum_Circular_Subarray.cpp	
@@ -0,0 +1,23 @@
+class Solution {
+public:
+    int maxSubarraySumCircular(vector<int>& A) {
+       if(A.size()==1){
+           return A[0];
+       } 
+    int sum=0;
+        for(int i=0;i<A.size();i++){
+            sum+=A[i];
+        }
+        int currMax=A[0],currMin=A[0],max_so_far=A[0],min_so_far=A[0];
+        for(int i=1;i<A.size();i++){
+            currMax= max(currMax+A[i],A[i]);
+            max_so_far= max(max_so_far,currMax);
+            currMin= min(currMin+A[i],A[i]);
+            min_so_far= min(min_so_far,currMin);
+        }
+        if(min_so_far==sum){
+            return max_so_far;
+        }
+        return max(max_so_far,sum-min_so_far);
+    }
+};

From 9a5cea4b91fd2484640e30e9059010efb89d610f Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Sun, 1 Nov 2020 21:52:38 +0530
Subject: [PATCH 138/203] Delete #41- First_missing_positive.cpp

---
 #41- First_missing_positive.cpp | 18 ------------------
 1 file changed, 18 deletions(-)
 delete mode 100644 #41- First_missing_positive.cpp

diff --git a/#41- First_missing_positive.cpp b/#41- First_missing_positive.cpp
deleted file mode 100644
index 391fdb1..0000000
--- a/#41- First_missing_positive.cpp	
+++ /dev/null
@@ -1,18 +0,0 @@
-class Solution {
-public:
-    int firstMissingPositive(vector<int>& nums) {
-        int n = nums.size();
-        vector<bool> nums_map(n+1);
-        for (int i = 0; i < n; i++) {
-            if(nums[i]<=n && nums[i]>0) { 
-                nums_map[nums[i]] = true;
-            }
-        }
-        for (int i=0; i<n; i++) {
-            i = i+1;
-            if (!nums_map[i]) 
-                return i; 
-        }
-        return n+1;
-    }
-};

From 3a15522284bfbc78005ceed16c92e70e1074e96a Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Sun, 1 Nov 2020 23:31:08 +0530
Subject: [PATCH 139/203] Update README.md

---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 58eef1c..0a27a56 100644
--- a/README.md
+++ b/README.md
@@ -28,4 +28,4 @@ However If You think that you have some great Resources and you love to contribu
  # HACKTOBERFEST STATS
 
 ***_Congratulations!🎉 You Made it!_***
-I would like to thank all the Contributor who have participated in Hacktoberfest this year By DigitalOcean and Successfully contributed to **C-plus-plus-Alogrithms** Repository. Whether it was your first time in the Open Source or having experience, Always remember _Every Expert was once a Beginner_.
+Thanks to all the Contributor who had participated in Hacktoberfest this year By DigitalOcean and Successfully contributed to **C-plus-plus-Alogrithms** Repository. Whether it was first time in the Open Source or having experience, Always remember _Every Expert was once a Beginner_.

From ec8bd9e4ac893cd24af2c5be410ac342e89150a3 Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Sun, 1 Nov 2020 23:33:44 +0530
Subject: [PATCH 140/203] Create #724-Find_Pivot_Index.cpp

---
 .../LeetCode/#724-Find_Pivot_Index.cpp        | 20 +++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#724-Find_Pivot_Index.cpp

diff --git a/ONLINE JUDGE/LeetCode/#724-Find_Pivot_Index.cpp b/ONLINE JUDGE/LeetCode/#724-Find_Pivot_Index.cpp
new file mode 100644
index 0000000..77a62b0
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#724-Find_Pivot_Index.cpp	
@@ -0,0 +1,20 @@
+/* https://leetcode.com/problems/find-pivot-index/ */
+
+
+class Solution {
+public:
+    int pivotIndex(vector<int>& nums) {
+       int sum=0,leftsum=0;
+        for(int i=0;i<nums.size();i++){
+            sum+=nums[i];
+        }
+        for(int i=0;i<nums.size();i++){
+            sum-=nums[i];
+        if(leftsum==sum){
+            return i;
+        }
+            leftsum+=nums[i];
+        }
+        return -1;
+    }
+};

From d83bea318cb28cf0dc98368a114d4e8cb4fc15bc Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Sun, 10 Jan 2021 12:04:31 +0530
Subject: [PATCH 141/203] Create #500-Keyboard Row.cpp

---
 ONLINE JUDGE/LeetCode/#500-Keyboard Row.cpp | 12 ++++++++++++
 1 file changed, 12 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#500-Keyboard Row.cpp

diff --git a/ONLINE JUDGE/LeetCode/#500-Keyboard Row.cpp b/ONLINE JUDGE/LeetCode/#500-Keyboard Row.cpp
new file mode 100644
index 0000000..1a578bc
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#500-Keyboard Row.cpp	
@@ -0,0 +1,12 @@
+class Solution {
+public:
+    vector<string> findWords(vector<string>& words) {
+    vector<string> key = {"QWERTYUIOPqwertyuiop", "ASDFGHJKLasdfghjkl", "ZXCVBNMzxcvbnm"};
+	vector<string> vec;
+	for (auto word : words)
+		for (auto row : key)
+			if (word.find_first_not_of(row) == string::npos)   // STL Function for finding the word that are not present in the Keyboard
+				vec.push_back(word);
+	return vec;
+    }
+};

From 4bbbf798015c9d95219cd736b0aaced1c0d17dda Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Mon, 1 Feb 2021 16:45:40 +0530
Subject: [PATCH 142/203] Create #451- Sort_Characters_By_Frequency.cpp

---
 .../#451- Sort_Characters_By_Frequency.cpp    | 47 +++++++++++++++++++
 1 file changed, 47 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#451- Sort_Characters_By_Frequency.cpp

diff --git a/ONLINE JUDGE/LeetCode/#451- Sort_Characters_By_Frequency.cpp b/ONLINE JUDGE/LeetCode/#451- Sort_Characters_By_Frequency.cpp
new file mode 100644
index 0000000..d0ed56b
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#451- Sort_Characters_By_Frequency.cpp	
@@ -0,0 +1,47 @@
+/*Given a string, sort it in decreasing order based on the frequency of characters.
+
+Example 1:
+
+Input:
+"tree"
+
+Output:
+"eert"
+
+Explanation:
+'e' appears twice while 'r' and 't' both appear once.
+So 'e' must appear before both 'r' and 't'. Therefore "eetr" is also a valid answer.
+*/
+
+
+```cpp
+
+//Solution by codewithdev
+class Solution {
+public:
+    static bool compare(pair<char,int>&a, pair<char,int>&b){
+        return a.second>b.second;
+    }
+    string frequencySort(string s) {
+    unordered_map<char,int>mp;
+        for(int i=0;i<s.size();i++){
+            mp[s[i]]++;
+        }
+        string ans="";
+        vector<pair<char,int>>vec;
+        for(auto x:mp){
+            vec.push_back(make_pair(x.first,x.second));
+        }
+        sort(vec.begin(),vec.end(),compare);
+        for(auto x:vec){
+            while(x.second>0){
+                ans+=x.first;
+                x.second--;
+            }
+        }
+        return ans;
+        
+    }
+};
+
+```

From 691c2eb96ca7b4692ba127e7372e932e1193269b Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Mon, 1 Feb 2021 18:39:22 +0530
Subject: [PATCH 143/203] Create #739- Daily_Temperatures.cpp

---
 .../LeetCode/#739- Daily_Temperatures.cpp     | 27 +++++++++++++++++++
 1 file changed, 27 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#739- Daily_Temperatures.cpp

diff --git a/ONLINE JUDGE/LeetCode/#739- Daily_Temperatures.cpp b/ONLINE JUDGE/LeetCode/#739- Daily_Temperatures.cpp
new file mode 100644
index 0000000..ef75859
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#739- Daily_Temperatures.cpp	
@@ -0,0 +1,27 @@
+/*Given a list of daily temperatures T, return a list such that, for each day in the input, tells you how many 
+days you would have to wait until a warmer temperature. If there is no future day for which this is possible, put 0 instead.
+
+For example, given the list of temperatures T = [73, 74, 75, 71, 69, 72, 76, 73], your output should be [1, 1, 4, 2, 1, 1, 0, 0].*/
+
+
+```cpp
+
+class Solution {
+public:
+    vector<int> dailyTemperatures(vector<int>& T) {
+        int n= T.size();
+        stack<int>s;
+        vector<int>ans(n,0);
+        for(int i=0;i<n;i++){
+        while(!s.empty() and T[s.top()]<T[i]){
+            int j= s.top();
+            s.pop();
+            ans[j]= i-j;
+        }
+        s.push(i);
+    }
+    return ans;
+    }
+
+};
+```

From 537b1da94b85c70fc75fccac5071ff0b1e877418 Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Wed, 3 Feb 2021 15:31:23 +0530
Subject: [PATCH 144/203] Create Invert-a-Binary-Tree.cpp

---
 18-Binary Tree/Invert-a-Binary-Tree.cpp | 93 +++++++++++++++++++++++++
 1 file changed, 93 insertions(+)
 create mode 100644 18-Binary Tree/Invert-a-Binary-Tree.cpp

diff --git a/18-Binary Tree/Invert-a-Binary-Tree.cpp b/18-Binary Tree/Invert-a-Binary-Tree.cpp
new file mode 100644
index 0000000..615c40a
--- /dev/null
+++ b/18-Binary Tree/Invert-a-Binary-Tree.cpp	
@@ -0,0 +1,93 @@
+
+
+/*Input:
+
+     4
+   /   \
+  2     7
+ / \   / \
+1   3 6   9
+Output:
+
+     4
+   /   \
+  7     2
+ / \   / \
+9   6 3   1
+*/
+
+
+
+#include<iostream>
+using namespace std;
+struct treenode{
+ int data;
+ treenode*left;
+ treenode*right;
+};
+
+struct treenode* createNode(int d){
+    struct treenode*root= new treenode;
+    root->data= d;
+    root->left= NULL;
+    root->right= NULL;
+    return root;    
+}
+
+void flipNodes(treenode*root){
+    if(root==NULL){
+        return;
+    }
+   treenode*temp= root->left;
+   root->left= root->right;
+   root->right= temp;
+}
+treenode*invertBinaryTree(treenode*root){
+    flipNodes(root);
+    return root;
+}
+
+int heightofTree(treenode*root){
+    if(root==NULL){
+        return 0;
+    }
+    return max(heightofTree(root->left), heightofTree(root->right))+1;
+}
+
+void givenlevel(treenode*root, int lev){
+    if(root==NULL){
+        return;
+    }
+    if(lev==1){
+        cout<<root->data<<" ";
+    }
+    else if(lev>1){
+        givenlevel(root->left,lev-1);
+        givenlevel(root->right,lev-1);
+    }
+}
+
+void printLevelwise(treenode*root){
+    int height= heightofTree(root);
+    int i;
+    for(i=1;i<=height;i++){
+        givenlevel(root,i);
+   }
+}
+
+int main(){
+struct treenode*root= NULL;
+root= createNode(4);
+root->left= createNode(2);
+root->right= createNode(7);
+root->left->right= createNode(3);
+root->left->left= createNode(1);
+root->right->left= createNode(6);
+root->right->right= createNode(9);
+printLevelwise(root);
+cout<<endl;
+invertBinaryTree(root);
+printLevelwise(root);
+
+return 0;
+}

From 73075c6d9dcc57fc1c281a8062881e3d9e10a385 Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Wed, 3 Feb 2021 15:32:27 +0530
Subject: [PATCH 145/203] Create #226-Invert-Binary-Tree.cpp

---
 .../LeetCode/#226-Invert-Binary-Tree.cpp        | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#226-Invert-Binary-Tree.cpp

diff --git a/ONLINE JUDGE/LeetCode/#226-Invert-Binary-Tree.cpp b/ONLINE JUDGE/LeetCode/#226-Invert-Binary-Tree.cpp
new file mode 100644
index 0000000..3642105
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#226-Invert-Binary-Tree.cpp	
@@ -0,0 +1,17 @@
+class Solution {
+public:
+    void mirror(TreeNode*root){
+        if(root==NULL){
+            return;
+        }
+        mirror(root->left);
+        mirror(root->right);
+        TreeNode*temp= root->left;
+        root->left= root->right;
+        root->right= temp;
+    }
+    TreeNode* invertTree(TreeNode* root) {
+       mirror(root);
+        return root;
+    }
+};

From 9c326ce961c7f7bb2fdbbd7652c6b467cdfcbeac Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Sat, 17 Apr 2021 14:24:59 +0530
Subject: [PATCH 146/203] Create #31-Next Permutation.cpp

---
 .../LeetCode/#31-Next Permutation.cpp         | 24 +++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#31-Next Permutation.cpp

diff --git a/ONLINE JUDGE/LeetCode/#31-Next Permutation.cpp b/ONLINE JUDGE/LeetCode/#31-Next Permutation.cpp
new file mode 100644
index 0000000..fb8db09
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#31-Next Permutation.cpp	
@@ -0,0 +1,24 @@
+#Problem Link: https://leetcode.com/problems/next-permutation/
+
+class Solution {
+public:
+    void nextPermutation(vector<int>& nums) {
+        int n= nums.size();
+        int k,l;
+        for(k=n-2;k>=0;--k){
+            if(nums[k]<nums[k+1])
+                break;
+        }
+             if(k<0)
+             {
+                 reverse(nums.begin(),nums.end());
+             }else{
+                 for(l=n-1;l>k;--l){
+                     if(nums[l]>nums[k])
+                         break;
+                 }
+                 swap(nums[k],nums[l]);
+                 reverse(nums.begin()+k+1, nums.end());
+             }
+        }
+};

From 96b1774b9c4de92e7ab56618de04c585f5b18191 Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Mon, 31 May 2021 05:27:31 +0530
Subject: [PATCH 147/203] Create alternate_pos_neg.cpp

---
 03-Arrays/alternate_pos_neg.cpp | 45 +++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)
 create mode 100644 03-Arrays/alternate_pos_neg.cpp

diff --git a/03-Arrays/alternate_pos_neg.cpp b/03-Arrays/alternate_pos_neg.cpp
new file mode 100644
index 0000000..8f6652c
--- /dev/null
+++ b/03-Arrays/alternate_pos_neg.cpp
@@ -0,0 +1,45 @@
+/*Problem Statement
+
+Given an unsorted array Arr of N positive and negative numbers. Your task is to create an array of alternate positive and negative numbers without changing the relative order of positive and negative numbers.*/
+
+#include<bits/stdc++.h>
+using namespace std;
+void rearrange(int *arr, int n){
+   vector<int>pos,neg;
+   for(int i=0;i<n;i++){
+      if(arr[i]<0)
+      neg.push_back(arr[i]);
+      else
+      pos.push_back(arr[i]);
+   }
+
+   int i=0, j=0,k=0;
+   while(i<pos.size() and j<neg.size())
+   {
+      arr[k++]= pos[i++];
+      arr[k++]= neg[j++];
+   }
+   while(i<pos.size())
+   {
+      arr[k++]= pos[i++];
+   }
+   while(j<neg.size())
+   {
+      arr[k++]= neg[j++];
+   }
+
+}
+
+
+int main(){
+  int n;
+  cin>>n;
+  int *arr= new int[n];
+  for(int i=0;i<n;i++){
+   cin>>arr[i];
+  }
+  rearrange(arr,n);
+  for(int i=0;i<n;i++){
+   cout<<arr[i]<<" ";
+  }
+}

From cfe56aaae9485de242dfad46b9757bce8a194bd7 Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Sun, 6 Jun 2021 20:08:52 +0530
Subject: [PATCH 148/203] Create #45- Jump_Game_2.cpp

---
 ONLINE JUDGE/LeetCode/#45- Jump_Game_2.cpp | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#45- Jump_Game_2.cpp

diff --git a/ONLINE JUDGE/LeetCode/#45- Jump_Game_2.cpp b/ONLINE JUDGE/LeetCode/#45- Jump_Game_2.cpp
new file mode 100644
index 0000000..968c3ff
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#45- Jump_Game_2.cpp	
@@ -0,0 +1,18 @@
+class Solution {
+public:
+    int jump(vector<int>& nums) {
+        int jumps=0;
+        int n= nums.size();
+        int maxjumps=0;
+        int currjumps=0;
+        for(int i=0;i<n-1;i++){ 
+            maxjumps= max(maxjumps, i+nums[i]);
+            if(i==currjumps)  
+            {
+                jumps++;
+                currjumps= maxjumps;
+            }
+        }
+        return jumps;
+    }
+};

From 4dba4d01187292f6f6474a23e208ecfd7bcea400 Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <44609609+codewithdev@users.noreply.github.com>
Date: Mon, 7 Jun 2021 15:55:25 +0530
Subject: [PATCH 149/203] Create #55 Jump_Game.cpp

---
 ONLINE JUDGE/#55 Jump_Game.cpp | 12 ++++++++++++
 1 file changed, 12 insertions(+)
 create mode 100644 ONLINE JUDGE/#55 Jump_Game.cpp

diff --git a/ONLINE JUDGE/#55 Jump_Game.cpp b/ONLINE JUDGE/#55 Jump_Game.cpp
new file mode 100644
index 0000000..bfa5385
--- /dev/null
+++ b/ONLINE JUDGE/#55 Jump_Game.cpp	
@@ -0,0 +1,12 @@
+class Solution {
+public:
+    bool canJump(vector<int>& nums) {
+        int reachable=0;
+        for(int i=0;i<nums.size();i++){
+            if(reachable<i)
+                return false;
+            reachable= max(reachable, i+nums[i]);
+        }
+        return true;
+    }
+};

From d2f012804a6aa9652e579afa5bcb9496995ef4a9 Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <idevprakaash@gmail.com>
Date: Sun, 12 Sep 2021 10:47:42 +0530
Subject: [PATCH 150/203] Update README.md

---
 README.md | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/README.md b/README.md
index 0a27a56..38b2f08 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,7 @@
  </p>
 
 # C++ DSA 
-Repo contains some most common Data Structure and Algorithm in cpp. Which will useful in future application of Competitive Programming as well Interview Preparation.
+Repo contains some most common Data Structure and Algorithm in C++ that will helpful to grasp the concept of various algorithm, working and also will help you in future application of Competitive Programming as well Interview Preparation.
 
 
  Hi :wave:
@@ -20,9 +20,7 @@ The Data Structure is the :heart: of Computer Science and Algorithms are the ste
 Some Most Comman Data Structure are like Array, Queue, Stack, Tree, Hash, Heap etc. Mastering these Data Structure will help you to solve many problems while you are doing competitive Programming or sitting for the Tech Interview. 
 
 
-However If You think that you have some great Resources and you love to contribute you can directly create a Pull Request [Check PR Instructions)](https://github.com/codewithdev/C-plus-plus-Algorithms/blob/master/CONTRIBUTING.md).
-
- 
+However If You think that you have some great resources and you'd love to contribute in the repo then create a Pull Request [Check PR Instructions)](https://github.com/codewithdev/C-plus-plus-Algorithms/blob/master/CONTRIBUTING.md) by forking this repo [Fork Here](https://github.com/codewithdev/C-plus-plus-Algorithms).
  
  
  # HACKTOBERFEST STATS

From 70253059b8cdfda91b49de5ba566721b081fefcf Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <idevprakaash@gmail.com>
Date: Thu, 16 Sep 2021 14:23:20 +0530
Subject: [PATCH 151/203] Update README.md

---
 README.md | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/README.md b/README.md
index 38b2f08..afd50d5 100644
--- a/README.md
+++ b/README.md
@@ -23,7 +23,7 @@ Some Most Comman Data Structure are like Array, Queue, Stack, Tree, Hash, Heap e
 However If You think that you have some great resources and you'd love to contribute in the repo then create a Pull Request [Check PR Instructions)](https://github.com/codewithdev/C-plus-plus-Algorithms/blob/master/CONTRIBUTING.md) by forking this repo [Fork Here](https://github.com/codewithdev/C-plus-plus-Algorithms).
  
  
- # HACKTOBERFEST STATS
+ # Our Awesome Contributors
+ 
+ [![Contributors](https://contrib.rocks/image?repo=codewithdev/C-plus-plus-Algorithms)](https://github.com/codewithdev/C-plus-plus-Algorithms/graphs/contributors)
 
-***_Congratulations!🎉 You Made it!_***
-Thanks to all the Contributor who had participated in Hacktoberfest this year By DigitalOcean and Successfully contributed to **C-plus-plus-Alogrithms** Repository. Whether it was first time in the Open Source or having experience, Always remember _Every Expert was once a Beginner_.

From 8712dc4e879b06b0ce9831313be59d46a714ee7e Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <idevprakaash@gmail.com>
Date: Thu, 16 Sep 2021 14:24:09 +0530
Subject: [PATCH 152/203] Update README.md

---
 README.md | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/README.md b/README.md
index afd50d5..7af6eb6 100644
--- a/README.md
+++ b/README.md
@@ -27,3 +27,11 @@ However If You think that you have some great resources and you'd love to contri
  
  [![Contributors](https://contrib.rocks/image?repo=codewithdev/C-plus-plus-Algorithms)](https://github.com/codewithdev/C-plus-plus-Algorithms/graphs/contributors)
 
+
+# Copyright
+
+Source code of this project is distributed under the Apache license version 2.0
+(see the LICENSE file in the project root).
+
+By submitting a pull request for this project, you agree to license your
+contribution under the Apache license 2.0 (source code) or CC BY 4.0

From 3b694d4c075605ddfe40e4d703c69db52a9214af Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <idevprakaash@gmail.com>
Date: Thu, 16 Sep 2021 14:38:39 +0530
Subject: [PATCH 153/203] Update README.md

---
 README.md | 29 +++++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 7af6eb6..b10936e 100644
--- a/README.md
+++ b/README.md
@@ -21,9 +21,34 @@ Some Most Comman Data Structure are like Array, Queue, Stack, Tree, Hash, Heap e
 
 
 However If You think that you have some great resources and you'd love to contribute in the repo then create a Pull Request [Check PR Instructions)](https://github.com/codewithdev/C-plus-plus-Algorithms/blob/master/CONTRIBUTING.md) by forking this repo [Fork Here](https://github.com/codewithdev/C-plus-plus-Algorithms).
+
+## Contributing to C-plus-plus-Algorithms
+
+## 🍴 Step 1. Fork this repository
+In order to contribute to C-plus-plus-Algorithms, you need to fork this repo, and develop on your own local clone.
+If you don't know how to do so, follow this guide!
+
+## 📖 Step 2. Get a Clone of Repo 
+First, move into your local cloned repository with the help of cd, after that navigate to the files.
+
+## 🛠 Step 3. Make your change
+Now you can start developing! All of the components are under the directory and associated code changes will automatically be reflected in the Repo.
+
+
+## 🏆 Step 4. Making your pull request
+Once you're done with making your changes, push everything to your local repository's branch.
+
+From here, you can open up a pull request from your forked repository's branch into C-plus-plus-Algortihms's master branch.
+
+In your PR description, explain the changes you made, why you made them, how to test them, and anything that might be a point of interest.
+
+Once you create your PR, it will be reviewed and hopefully merged quickly!
+
+## 🥂 Step 5. Pat yourself on the back
+Congrats, you're officially a Contributor!
+
  
- 
- # Our Awesome Contributors
+ ## 🎉Contributors
  
  [![Contributors](https://contrib.rocks/image?repo=codewithdev/C-plus-plus-Algorithms)](https://github.com/codewithdev/C-plus-plus-Algorithms/graphs/contributors)
 

From 1276e224d221b2962a3bd5683b2d8e3b0a3bd13b Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <idevprakaash@gmail.com>
Date: Fri, 1 Oct 2021 19:36:45 +0530
Subject: [PATCH 154/203] Update pull_request_template.md

---
 .github/pull_request_template.md | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md
index 201180a..a576905 100644
--- a/.github/pull_request_template.md
+++ b/.github/pull_request_template.md
@@ -1,11 +1,17 @@
-**Added the <Filename> Filename as**
+<!--
+Thank you for contributing to this project! You must fill out the information below before we can review this pull request. By explaining why you're making a change (or linking to a pull request) and what changes you've made.-->
 
+### What's being changed:
+<!-- Describe what content you added in the library or brief about your contribution -->
 
-**Changes Proposed <Describe> in the PR. Describe**
 
+### Checkoff the following:
 
-**I am assuring that the file is not redundant and making the Pull Request**
-- [ ] Yes
+- [ ]  Read [Contribution.md](https://github.com/codewithdev/C-plus-plus-Algorithms/blob/master/CONTRIBUTING.md)
+- [ ]  Created a new branch before committing.
+- [ ]  My File doesn't contain any duplicacy or misinformation (isn't available in the library).
+- [ ]  Added to the right category.
+- [ ]  Described what's being changed.
  
  Read {% include Contributing.md %}
 

From b12a303b1d36a8816571756de200e7ad5478a914 Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <idevprakaash@gmail.com>
Date: Fri, 1 Oct 2021 19:38:17 +0530
Subject: [PATCH 155/203] Update pull_request_template.md

---
 .github/pull_request_template.md | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md
index a576905..cbcd9ce 100644
--- a/.github/pull_request_template.md
+++ b/.github/pull_request_template.md
@@ -12,7 +12,10 @@ Thank you for contributing to this project! You must fill out the information be
 - [ ]  My File doesn't contain any duplicacy or misinformation (isn't available in the library).
 - [ ]  Added to the right category.
 - [ ]  Described what's being changed.
- 
+
+<!--
+Thanks again!
+-->
  Read {% include Contributing.md %}
 
   

From 43b293e74babc730a3939d52a07d3cf78cbea943 Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <idevprakaash@gmail.com>
Date: Fri, 1 Oct 2021 19:48:36 +0530
Subject: [PATCH 156/203] Update README.md

---
 README.md | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/README.md b/README.md
index b10936e..def166b 100644
--- a/README.md
+++ b/README.md
@@ -53,10 +53,3 @@ Congrats, you're officially a Contributor!
  [![Contributors](https://contrib.rocks/image?repo=codewithdev/C-plus-plus-Algorithms)](https://github.com/codewithdev/C-plus-plus-Algorithms/graphs/contributors)
 
 
-# Copyright
-
-Source code of this project is distributed under the Apache license version 2.0
-(see the LICENSE file in the project root).
-
-By submitting a pull request for this project, you agree to license your
-contribution under the Apache license 2.0 (source code) or CC BY 4.0

From d18f9413c241588c1ccce14b2bc0cee416a89ee6 Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <idevprakaash@gmail.com>
Date: Fri, 1 Oct 2021 19:51:55 +0530
Subject: [PATCH 157/203] Update README.md

---
 README.md | 1 +
 1 file changed, 1 insertion(+)

diff --git a/README.md b/README.md
index def166b..40d1c3d 100644
--- a/README.md
+++ b/README.md
@@ -50,6 +50,7 @@ Congrats, you're officially a Contributor!
  
  ## 🎉Contributors
  
+Big shoutout to all the contributors who have put their efforts to make it big!!
  [![Contributors](https://contrib.rocks/image?repo=codewithdev/C-plus-plus-Algorithms)](https://github.com/codewithdev/C-plus-plus-Algorithms/graphs/contributors)
 
 

From f079748078e7d2d7e6f2874caaae0892150ca087 Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <idevprakaash@gmail.com>
Date: Fri, 1 Oct 2021 19:52:28 +0530
Subject: [PATCH 158/203] Update README.md

---
 README.md | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 40d1c3d..14e3d67 100644
--- a/README.md
+++ b/README.md
@@ -50,7 +50,9 @@ Congrats, you're officially a Contributor!
  
  ## 🎉Contributors
  
-Big shoutout to all the contributors who have put their efforts to make it big!!
+Big shoutout to all the contributors who have put their efforts to make it big!! 🥇
+
+
  [![Contributors](https://contrib.rocks/image?repo=codewithdev/C-plus-plus-Algorithms)](https://github.com/codewithdev/C-plus-plus-Algorithms/graphs/contributors)
 
 

From 49b1c2385be094c00d08fdd0cf51348fecd1ccca Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <idevprakaash@gmail.com>
Date: Fri, 1 Oct 2021 20:00:38 +0530
Subject: [PATCH 159/203] Update pull_request_template.md

---
 .github/pull_request_template.md | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md
index cbcd9ce..80d0a50 100644
--- a/.github/pull_request_template.md
+++ b/.github/pull_request_template.md
@@ -11,6 +11,7 @@ Thank you for contributing to this project! You must fill out the information be
 - [ ]  Created a new branch before committing.
 - [ ]  My File doesn't contain any duplicacy or misinformation (isn't available in the library).
 - [ ]  Added to the right category.
+- [ ]  Applied correct labels.
 - [ ]  Described what's being changed.
 
 <!--

From f9c1259ecfc908bc20075d40d9f6f73b1aa3d04b Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <idevprakaash@gmail.com>
Date: Fri, 1 Oct 2021 20:03:23 +0530
Subject: [PATCH 160/203] Update pull_request_template.md

---
 .github/pull_request_template.md | 1 -
 1 file changed, 1 deletion(-)

diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md
index 80d0a50..cbcd9ce 100644
--- a/.github/pull_request_template.md
+++ b/.github/pull_request_template.md
@@ -11,7 +11,6 @@ Thank you for contributing to this project! You must fill out the information be
 - [ ]  Created a new branch before committing.
 - [ ]  My File doesn't contain any duplicacy or misinformation (isn't available in the library).
 - [ ]  Added to the right category.
-- [ ]  Applied correct labels.
 - [ ]  Described what's being changed.
 
 <!--

From 140398e766e3e2f2e258ea71a2d288fe9cbba62e Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <idevprakaash@gmail.com>
Date: Fri, 1 Oct 2021 20:15:19 +0530
Subject: [PATCH 161/203] Create label.yml

---
 .github/workflows/label.yml | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 .github/workflows/label.yml

diff --git a/.github/workflows/label.yml b/.github/workflows/label.yml
new file mode 100644
index 0000000..5cdc45e
--- /dev/null
+++ b/.github/workflows/label.yml
@@ -0,0 +1,22 @@
+# This workflow will triage pull requests and apply a label based on the
+# paths that are modified in the pull request.
+#
+# To use this workflow, you will need to set up a .github/labeler.yml
+# file with configuration.  For more information, see:
+# https://github.com/actions/labeler
+
+name: Labeler
+on: [pull_request]
+
+jobs:
+  label:
+
+    runs-on: ubuntu-latest
+    permissions:
+      contents: read
+      pull-requests: write
+
+    steps:
+    - uses: actions/labeler@v2
+      with:
+        repo-token: "${{ secrets.GITHUB_TOKEN }}"

From 3735559bafdd73e73ff28c87e203b4a4565090ef Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <idevprakaash@gmail.com>
Date: Fri, 1 Oct 2021 20:16:11 +0530
Subject: [PATCH 162/203] Create ^

---
 .github/^ | 2 ++
 1 file changed, 2 insertions(+)
 create mode 100644 .github/^

diff --git a/.github/^ b/.github/^
new file mode 100644
index 0000000..f00e811
--- /dev/null
+++ b/.github/^
@@ -0,0 +1,2 @@
+triaged:
+- "*"

From 858c85f6d37f712ac171ac2f9b805775e05237f9 Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <idevprakaash@gmail.com>
Date: Fri, 1 Oct 2021 21:24:47 +0530
Subject: [PATCH 163/203] Delete label.yml

---
 .github/workflows/label.yml | 22 ----------------------
 1 file changed, 22 deletions(-)
 delete mode 100644 .github/workflows/label.yml

diff --git a/.github/workflows/label.yml b/.github/workflows/label.yml
deleted file mode 100644
index 5cdc45e..0000000
--- a/.github/workflows/label.yml
+++ /dev/null
@@ -1,22 +0,0 @@
-# This workflow will triage pull requests and apply a label based on the
-# paths that are modified in the pull request.
-#
-# To use this workflow, you will need to set up a .github/labeler.yml
-# file with configuration.  For more information, see:
-# https://github.com/actions/labeler
-
-name: Labeler
-on: [pull_request]
-
-jobs:
-  label:
-
-    runs-on: ubuntu-latest
-    permissions:
-      contents: read
-      pull-requests: write
-
-    steps:
-    - uses: actions/labeler@v2
-      with:
-        repo-token: "${{ secrets.GITHUB_TOKEN }}"

From c9de0f98169d4611823bb0d302cc5235b8f083c2 Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <idevprakaash@gmail.com>
Date: Fri, 1 Oct 2021 21:24:57 +0530
Subject: [PATCH 164/203] Delete ^

---
 .github/^ | 2 --
 1 file changed, 2 deletions(-)
 delete mode 100644 .github/^

diff --git a/.github/^ b/.github/^
deleted file mode 100644
index f00e811..0000000
--- a/.github/^
+++ /dev/null
@@ -1,2 +0,0 @@
-triaged:
-- "*"

From b2a0097b81b65e905cdefe05f7fa724c97a4b098 Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <idevprakaash@gmail.com>
Date: Fri, 1 Oct 2021 21:25:32 +0530
Subject: [PATCH 165/203] Update pull_request_template.md

---
 .github/pull_request_template.md | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md
index cbcd9ce..1739055 100644
--- a/.github/pull_request_template.md
+++ b/.github/pull_request_template.md
@@ -11,6 +11,7 @@ Thank you for contributing to this project! You must fill out the information be
 - [ ]  Created a new branch before committing.
 - [ ]  My File doesn't contain any duplicacy or misinformation (isn't available in the library).
 - [ ]  Added to the right category.
+- [ ]  Added "add code" label.
 - [ ]  Described what's being changed.
 
 <!--

From f1aad425486ecab33c0d13e9d2523218d1df17f8 Mon Sep 17 00:00:00 2001
From: jineshparakh <jineshparakh@hotmail.com>
Date: Fri, 1 Oct 2021 22:13:43 +0530
Subject: [PATCH 166/203] Added Matrix Chain Multiplication DP Problem with
 comments

---
 24- Dynamic Programming/MCMMemoized.cpp | 81 +++++++++++++++++++++++++
 1 file changed, 81 insertions(+)
 create mode 100644 24- Dynamic Programming/MCMMemoized.cpp

diff --git a/24- Dynamic Programming/MCMMemoized.cpp b/24- Dynamic Programming/MCMMemoized.cpp
new file mode 100644
index 0000000..bb6812f
--- /dev/null
+++ b/24- Dynamic Programming/MCMMemoized.cpp	
@@ -0,0 +1,81 @@
+#include<bits/stdc++.h>
+using namespace std;
+#define ll long long
+#define ld long double
+#define rep(i,a,b) for(ll i=a;i<b;i++)
+#define repp(i,a,b) for(ll i=a;i<=b;i++)
+#define rrep(i,a,b) for(ll i=a;i>=b;i--)
+#define endl "\n"
+
+ll dp[1001][1001];
+ll MCM(ll a[], ll i, ll j) {
+    /*
+    The complete logic
+    Take the array: 40 20 30 10 30
+    Feel where to apply MCM. It should be applied where you feel you really don't
+    know what the answer is but feel like I have to partition at each point and check
+    which of them is the minimum.
+    The basic format of all MCM's is similar. Base condition needs to be thought about.
+    For the base condition think of the first invalid input. That will be it.
+    Now talking about the for loop.
+    In this we check for each k from i to j-1.
+    Selecting i and j at the starting is also very crucial. It can be selected by taking
+    an example and trial and error.
+    In this case if you initially take i to be 0, we get an invalid matrix as,
+    general matrix Ai=a[i-1]*a[i]. So i needs to be 1. Similarly j=n-1.
+    In the loop we partition at each k and find the smallest answer.
+    Now how does the last a[i - 1] * a[k] * a[j] thing come.
+    This comes because say we have, ((AB)(CD)).
+    After solving the inner braces we get (EF). It's answer should also be added to the
+    final ans.
+    How to find it?
+    ->Observe A starts at index i and ends at k, C starts at k+1 and ends at j.
+    So the dimensions are preserved for these entities... Think on this.
+    You'll get the hang of it.
+    It's OP;)
+
+    */
+    if (i >= j)
+        return 0LL;
+    if (dp[i][j] != -1)
+        return dp[i][j];
+    ll ans = LLONG_MAX;
+    for (ll k = i; k <= j - 1; k++) {
+        ll tempAns;
+        tempAns = MCM(a, i, k) + MCM(a, k + 1, j) + a[i - 1] * a[k] * a[j];
+        ans = min(ans, tempAns);
+    }
+    return dp[i][j] = ans;
+}
+int main() {
+    /*
+    MATRIX CHAIN MULTIPLICATION( aka MCM)
+    Given:
+    An integer n denoting the size of the array
+    a[i] is the ith array element.
+    Let array be:
+    40 20 30 10 30
+    It represents n-1 2D matrices viz.
+    A1= 40*20
+    A2=20*30
+    A3=30*10
+    A4=10*30
+    In short Ai= a[i-1]*a[i] size matrix.
+    We need to given the minimum cost of multiplying these matrices.
+    Cost Eg:
+    40*20 and 20*30 matrix are to be multiplied
+    -> Cost= 40*20*30
+    The cost differs by how you multiply the matrices
+    Eg:
+    Let the matrices be ABCD.
+    ((AB)(CD)) can have different cost than ((ABC)D).
+    */
+    ll n; cin >> n;
+    ll a[n];
+    rep(i, 0, n) cin >> a[i];
+    ll i = 1, j = n - 1;
+    memset(dp, -1, sizeof(dp));
+    cout << MCM(a, i, j);
+
+    return 0;
+}

From 6bd698b0fd5ca0af89fec5764997a4a00b10b27f Mon Sep 17 00:00:00 2001
From: jineshparakh <jineshparakh@hotmail.com>
Date: Fri, 1 Oct 2021 22:18:49 +0530
Subject: [PATCH 167/203] Added Recursion problems

---
 10- Recursion & Backtracking/LCS.cpp          | 53 ++++++++++++++
 .../countofSubsetsWithGivenDifference.cpp     | 49 +++++++++++++
 .../countofSubsetsWithgivenSum.cpp            | 42 +++++++++++
 .../deleteMiddleElementofStackRecursion.cpp   | 26 +++++++
 .../editDistanceRecursive.cpp                 | 40 +++++++++++
 .../isEqualSumPartitionPossible.cpp           | 58 +++++++++++++++
 .../isSubsetSumPossible.cpp                   | 72 +++++++++++++++++++
 .../sortArrayRecursion.cpp                    | 53 ++++++++++++++
 .../sortStackDescendingRecursion.cpp          | 43 +++++++++++
 9 files changed, 436 insertions(+)
 create mode 100644 10- Recursion & Backtracking/LCS.cpp
 create mode 100644 10- Recursion & Backtracking/countofSubsetsWithGivenDifference.cpp
 create mode 100644 10- Recursion & Backtracking/countofSubsetsWithgivenSum.cpp
 create mode 100644 10- Recursion & Backtracking/deleteMiddleElementofStackRecursion.cpp
 create mode 100644 10- Recursion & Backtracking/editDistanceRecursive.cpp
 create mode 100644 10- Recursion & Backtracking/isEqualSumPartitionPossible.cpp
 create mode 100644 10- Recursion & Backtracking/isSubsetSumPossible.cpp
 create mode 100644 10- Recursion & Backtracking/sortArrayRecursion.cpp
 create mode 100644 10- Recursion & Backtracking/sortStackDescendingRecursion.cpp

diff --git a/10- Recursion & Backtracking/LCS.cpp b/10- Recursion & Backtracking/LCS.cpp
new file mode 100644
index 0000000..110260d
--- /dev/null
+++ b/10- Recursion & Backtracking/LCS.cpp	
@@ -0,0 +1,53 @@
+#include<bits/stdc++.h>
+using namespace std;
+#define ll long long
+
+ll LCS(string X, string Y, ll n, ll m) {
+    /*
+    Base case:
+    If either one of the two strings becomes null string, we cannot choose
+    more from it.
+    So return 0.
+    */
+    if (n == 0 || m == 0)
+        return 0LL;
+    /*
+    Choice Diagram:
+    A. If the n-1th and m-1th character of both strings is equal, we select it and recur
+    for n-1 and m-1
+    B. If they are not equal, we have two choices.
+        1. Recur for n-1,m
+        2. Recur for n,m-1
+        We have to find the LCS, so we will choose the max among the two cases.
+    */
+    if (X[n - 1] == Y[m - 1])
+        return LCS(X, Y, n - 1, m - 1) + 1LL;
+    else {
+        return max(LCS(X, Y, n - 1, m), LCS(X, Y, n, m - 1));
+    }
+}
+int main() {
+   
+    /*
+    LONGEST COMMON SUBSEQUENCE LENGTH
+    Given two string X and Y, find the length of LCS between them.
+    */
+    string X, Y; cin >> X >> Y;
+    ll n = X.size(), m = Y.size();
+    cout << LCS(X, Y, n, m) << endl;
+
+    /*
+    Sample Input:
+    AGGTAB
+    GXTXAYB
+    Output: 
+    4
+    Sample Input:
+    ABCDGH
+    AEDFHR
+    Output:
+    3
+    */
+
+    return 0;
+}
diff --git a/10- Recursion & Backtracking/countofSubsetsWithGivenDifference.cpp b/10- Recursion & Backtracking/countofSubsetsWithGivenDifference.cpp
new file mode 100644
index 0000000..57ee622
--- /dev/null
+++ b/10- Recursion & Backtracking/countofSubsetsWithGivenDifference.cpp	
@@ -0,0 +1,49 @@
+#include<bits/stdc++.h>
+using namespace std;
+#define ll long long
+
+ll findCountofSubsets(ll a[], ll n, ll S) {
+    if (n == 0 && S == 0)
+        return 1;
+    if (n == 0 && S != 0)
+        return 0;
+    if (n != 0 && S == 0)
+        return 1;
+    if (a[n - 1] <= S) {
+        return findCountofSubsets(a, n - 1, S) + findCountofSubsets(a, n - 1, S - a[n - 1]);
+    }
+    else return findCountofSubsets(a, n - 1, S);
+}
+int main() {
+   
+    /*
+    Given n as the size of array
+    a[i] is the ith element of the array
+    S is the requeired absolute difference between the two partitions of the array
+    To find:
+    Count the number of valid pairs of subsets such that the given difference
+    is obtained
+    */
+    ll n, S; cin >> n >> S;
+    ll a[n];
+    ll sum = 0;
+    for(ll i = 0; i < n; i++) {
+        cin >> a[i];
+        sum += a[i];
+    }
+    if ((sum + S) & 1)
+        cout << 0 << endl;
+    else
+        /*
+        Why (sum+S)/2;
+        sum(subset1)-sum(subset2)=difference(S);
+        sum(subset1)+sub(subset2)=sumofArray(sum);
+        Add these two
+        sum(subset1)=(S+sum)/2
+        */
+        cout << findCountofSubsets(a, n, (sum + S) / 2) << endl;
+
+    return 0;
+}
+
+
diff --git a/10- Recursion & Backtracking/countofSubsetsWithgivenSum.cpp b/10- Recursion & Backtracking/countofSubsetsWithgivenSum.cpp
new file mode 100644
index 0000000..66004ee
--- /dev/null
+++ b/10- Recursion & Backtracking/countofSubsetsWithgivenSum.cpp	
@@ -0,0 +1,42 @@
+#include <bits/stdc++.h>
+using namespace std;
+#define ll long long
+
+ll countSubsets(ll a[], ll n, ll S) {
+    if (n == 0 && S == 0)
+        return 1;
+    else if (n != 0 && S == 0)
+        return 1;
+    else if (n == 0 && S != 0)
+        return 0;
+    if (a[n - 1] <= S) {
+        return countSubsets(a, n - 1, S) + countSubsets(a, n - 1, S - a[n - 1]);
+    }
+    else
+        return countSubsets(a, n - 1, S);
+}
+int main() {
+    /*
+    Given n as the size of the array and S as the required sum.
+    a[i] is the ith element of the array which is >0
+    To find:
+    The count of subsets having the sum S
+    Similar to the subset sum problem, just instead of || use +
+    */
+    ll n, S;
+    cin >> n >> S;
+    ll a[n];
+    for (ll i = 0; i < n; i++)
+        cin >> a[i];
+    cout << countSubsets(a, n, S) << endl;
+
+    /*
+    INPUT:
+    6 10
+    2 3 5 6 8 10
+    OUTPUT: 
+    3
+    */
+    return 0;
+}
+
diff --git a/10- Recursion & Backtracking/deleteMiddleElementofStackRecursion.cpp b/10- Recursion & Backtracking/deleteMiddleElementofStackRecursion.cpp
new file mode 100644
index 0000000..66906b3
--- /dev/null
+++ b/10- Recursion & Backtracking/deleteMiddleElementofStackRecursion.cpp	
@@ -0,0 +1,26 @@
+#include<bits/stdc++.h>
+using namespace std;
+#define ll long long
+void deleteMiddleElement(stack<ll> &s, ll n) {
+	if (s.empty())
+		return;
+	ll val = s.top();
+	s.pop();
+	deleteMiddleElement(s, n - 1);
+	if (n != 0)  // if the element is middle element then do not add it
+		s.push(val);
+}
+int main() {
+	stack<ll> s;
+	ll n; cin >> n;
+	for (ll i = 0; i < n; i++) {
+		ll x; cin >> x;
+		s.push(x);
+	}
+	deleteMiddleElement(s, s.size() / 2);
+	while (!s.empty()) {
+		cout << s.top() << " ";
+		s.pop();
+
+	}
+}
\ No newline at end of file
diff --git a/10- Recursion & Backtracking/editDistanceRecursive.cpp b/10- Recursion & Backtracking/editDistanceRecursive.cpp
new file mode 100644
index 0000000..ba91351
--- /dev/null
+++ b/10- Recursion & Backtracking/editDistanceRecursive.cpp	
@@ -0,0 +1,40 @@
+#include<bits/stdc++.h>
+using namespace std;
+#define ll long long
+
+ll editDistance(string X, string Y, ll n, ll m) {
+    /*
+    The base conditions:
+    If either of the strings is empty you need the corresponding lengths to 
+    make them same
+    If the characters are same do nothing and go for a smaller input
+    If not, we need to do something which costs 1 and them we choose the least cost amongst
+    insert, replace and remove.
+    Replace-> call for(n-1,m-1)
+    Insert-> call for(n,m-1)
+    Remove->call for(n-1,m)
+
+    */
+    if (n == 0)
+        return m;
+    if (m == 0)
+        return n;
+    if (X[n - 1] == Y[m - 1])
+        return editDistance(X, Y, n - 1, m - 1);
+    else
+        return 1 + min(editDistance(X, Y, n - 1, m - 1), min(editDistance(X, Y, n - 1, m), editDistance(X, Y, n, m - 1)));
+}
+int main() {
+
+    /*
+    Edit Distance.
+    Convert String X to string Y by doing insert, replace and remove.
+    All three are of the same cost.
+    Find the minimum cost of conversion
+    */
+    string X, Y; cin >> X >> Y;
+    cout << editDistance(X, Y, X.size(), Y.size());
+
+    return 0;
+}
+
diff --git a/10- Recursion & Backtracking/isEqualSumPartitionPossible.cpp b/10- Recursion & Backtracking/isEqualSumPartitionPossible.cpp
new file mode 100644
index 0000000..d714dcc
--- /dev/null
+++ b/10- Recursion & Backtracking/isEqualSumPartitionPossible.cpp	
@@ -0,0 +1,58 @@
+#include <bits/stdc++.h>
+using namespace std;
+#define ll long long
+
+bool equalSumPartition(ll a[], ll n, ll S) {
+    if (n == 0 && S == 0)
+        return 1;
+    if (n == 0 && S != 0)
+        return 0;
+    if (n != 0 && S == 0)
+        return 1;
+    if (a[n - 1] <= S) {
+        return equalSumPartition(a, n - 1, S) || equalSumPartition(a, n - 1, S - a[n - 1]);
+    }
+    else
+        return equalSumPartition(a, n - 1, S);
+}
+int main() {
+    /*
+    Given Input:
+    n denotes the number of elements in the array
+    a[i] is the ith element of the array
+    S is the sum of the array
+    To find:
+    Return True if the array can be divided into 2 subsets of equal sum else return false
+
+
+    Interpretations:
+    Problem is similar to 0-1 knapsack.
+    We gotta make choices.
+        a. include it
+        b. don't include the element.
+
+    */
+    ll n, S=0;
+    cin >> n;
+    ll a[n];
+    for (ll i = 0; i < n; i++)
+        cin >> a[i], S += a[i];
+    if (S & 1)
+        cout << "NO" << endl;
+    else
+        cout << (equalSumPartition(a, n, S / 2) ? "YES" : "NO") << endl;
+    /*
+    Sample Input:
+    5
+    2 3 5 7 8
+    Output:
+    NO
+
+    Sample Input:
+    5
+    5 1 1 1 2
+    Output: YES
+    */
+
+    return 0;
+}
\ No newline at end of file
diff --git a/10- Recursion & Backtracking/isSubsetSumPossible.cpp b/10- Recursion & Backtracking/isSubsetSumPossible.cpp
new file mode 100644
index 0000000..e2cc411
--- /dev/null
+++ b/10- Recursion & Backtracking/isSubsetSumPossible.cpp	
@@ -0,0 +1,72 @@
+#include <bits/stdc++.h>
+using namespace std;
+#define ll long long
+
+bool subsetSum(ll a[], ll n, ll S)
+{
+    /*
+    Base case:
+    If n==0 && S==0 we can have an empty subset
+    If n==0 && S!=0 we cannot have empty subset
+    If n!=0 && S==0 we can choose an empty subset
+    Think of the smallest possible input which keeps on changing in the 
+    revursive code.
+    */
+    if (n == 0 && S == 0)
+        return 1;
+    else if (n == 0 && S != 0)
+        return 0;
+    else if (n != 0 && S == 0)
+        return 1;
+
+    /*
+    The choice diagram.
+    Start from the back.
+    We used max in the 0-1 knapsack, here we use || because if either of the two sums 
+    is possible we should get a 1. Similar to the boolean max thing(is || only).
+
+    */
+    if (a[n - 1] <= S) {
+        return subsetSum(a, n - 1, S - a[n - 1]) || subsetSum(a, n - 1, S);
+    }
+    else {
+        return subsetSum(a, n - 1, S);
+    }
+}
+int main() {
+
+    /*
+    Given Input:
+    n denotes the number of elements in the array
+    a[i] is the ith element of the array
+    S is the target sum.
+    To find:
+    Return True if any subset with the given sum exists else return false.
+
+    Interpretations:
+    Problem is similar to 0-1 knapsack.
+    We gotta make choices.
+        a. include it
+        b. don't include the element.
+
+    */
+    ll n, S;
+    cin >> n >> S;
+    ll a[n];
+    for (ll i = 0; i < n; i++)
+        cin >> a[i];
+    cout << (subsetSum(a, n, S) ? "YES" : "NO") << endl;
+    /*
+    Sample Input:
+    5 1
+    2 3 5 7 8
+    Output:
+    NO
+
+    Sample Input:
+    5 11
+    2 3 5 7 8
+    Output: YES
+    */
+    return 0;
+}
diff --git a/10- Recursion & Backtracking/sortArrayRecursion.cpp b/10- Recursion & Backtracking/sortArrayRecursion.cpp
new file mode 100644
index 0000000..dd4cf9c
--- /dev/null
+++ b/10- Recursion & Backtracking/sortArrayRecursion.cpp	
@@ -0,0 +1,53 @@
+#include<bits/stdc++.h>
+using namespace std;
+#define ll long long
+#define pb push_back
+
+void insert(vector<ll> &v, ll value) {
+    if (v.size() == 0 || v[v.size() - 1] <= value) {
+        v.pb(value);
+        return;
+    }
+    ll ele = v[v.size() - 1];
+    v.pop_back();
+    insert(v, value);
+    v.pb(ele);
+}
+void sortRecursively(vector<ll> &v) {
+    if (v.size() == 1) {
+        return;
+    }
+    ll val = v[v.size() - 1];
+    v.pop_back();
+    sortRecursively(v);
+    insert(v, val);
+}
+int main() {
+  
+    /*
+    Thought Process:
+    Firstly decide a clear task which you want your recursive function to do.
+    It will do that only.
+    Do not change the task it does in between the question. 
+    It should be fixed.
+    sortRecursively function takes a vector removes the last elemnt and sorts the remaining part.
+    You do not need to worry how, it will. It is really MAGICAL.
+    After removing the last element we need to insert it in the correct place.
+    So we define an insert function for that.
+    
+    */
+    ll n; cin >> n;
+    vector<ll> v;
+    for(ll i = 0; i < n; i++) {
+        ll x; cin >> x;
+        v.pb(x);
+    }
+    sortRecursively(v);
+    cout << v.size() << endl;
+    for (auto i : v)
+        cout << i << " ";
+    cout << endl;
+
+    return 0;
+}
+
diff --git a/10- Recursion & Backtracking/sortStackDescendingRecursion.cpp b/10- Recursion & Backtracking/sortStackDescendingRecursion.cpp
new file mode 100644
index 0000000..4a242a5
--- /dev/null
+++ b/10- Recursion & Backtracking/sortStackDescendingRecursion.cpp	
@@ -0,0 +1,43 @@
+#include<bits/stdc++.h>
+using namespace std;
+#define ll long long
+
+void insert(stack<ll> &s, ll value) {
+    if (s.size() == 0 || s.top() <= value) {
+        s.push(value);
+        return;
+    }
+    ll ele = s.top();
+    s.pop();
+    insert(s, value);
+    s.push(ele);
+}
+void sortRecursively(stack<ll> &s) {
+    if (s.size() == 1) {
+        return;
+    }
+    ll val = s.top();
+    s.pop();
+    sortRecursively(s);
+    insert(s, val);
+}
+int main() {
+
+    ll n; cin >> n;
+    stack<ll> s;
+    for(int i = 0; i < n; i++) {
+        ll x; cin >> x;
+        s.push(x);
+    }
+    sortRecursively(s);
+    cout << s.size() << endl;
+    while (!s.empty()) {
+        cout << s.top() << " ";
+        s.pop();
+    }
+    cout << endl;
+
+
+    return 0;
+}
+

From 7e4d5d69c9d80cb8e63c5db7a724e53d32e1dd52 Mon Sep 17 00:00:00 2001
From: thecoderebel <91749535+thecoderebel@users.noreply.github.com>
Date: Fri, 1 Oct 2021 22:21:34 +0530
Subject: [PATCH 168/203] Create #78- Subsets.cpp

---
 ONLINE JUDGE/LeetCode/#78- Subsets.cpp | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#78- Subsets.cpp

diff --git a/ONLINE JUDGE/LeetCode/#78- Subsets.cpp b/ONLINE JUDGE/LeetCode/#78- Subsets.cpp
new file mode 100644
index 0000000..1c28a0b
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#78- Subsets.cpp	
@@ -0,0 +1,24 @@
+ //Problem Name: Subsets
+// Problem link: https://leetcode.com/problems/subsets/
+
+//Code:
+
+class Solution {
+public:
+    vector<vector<int>> subsets(vector<int>& nums) {
+              int n = nums.size();
+        vector<vector<int>> ans;
+        for(int i=0;i< pow(2,n);i++){
+            vector<int> tmp;
+            for(int j=0;j<n;j++){
+                if(i & (1<<j)){
+                    tmp.push_back(nums[j]);
+                }
+            }
+            ans.push_back(tmp);
+           
+        }
+        return ans;
+    }
+};
+

From 4217cef179698e087acdc7b1fb68e9a756195d2d Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <idevprakaash@gmail.com>
Date: Fri, 1 Oct 2021 22:37:18 +0530
Subject: [PATCH 169/203] Update pull_request_template.md

---
 .github/pull_request_template.md | 1 -
 1 file changed, 1 deletion(-)

diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md
index 1739055..d597069 100644
--- a/.github/pull_request_template.md
+++ b/.github/pull_request_template.md
@@ -17,7 +17,6 @@ Thank you for contributing to this project! You must fill out the information be
 <!--
 Thanks again!
 -->
- Read {% include Contributing.md %}
 
   
 

From df1ab589686161b3af88df9b25ea8671585435f2 Mon Sep 17 00:00:00 2001
From: thecoderebel <91749535+thecoderebel@users.noreply.github.com>
Date: Sat, 2 Oct 2021 00:57:26 +0530
Subject: [PATCH 170/203] Added Grumpy bookstore.cpp

---
 .../LeetCode/#1052- Grumpy-Bookstore.cpp      | 40 +++++++++++++++++++
 1 file changed, 40 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#1052- Grumpy-Bookstore.cpp

diff --git a/ONLINE JUDGE/LeetCode/#1052- Grumpy-Bookstore.cpp b/ONLINE JUDGE/LeetCode/#1052- Grumpy-Bookstore.cpp
new file mode 100644
index 0000000..e418e08
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#1052- Grumpy-Bookstore.cpp	
@@ -0,0 +1,40 @@
+//Problem Name: Grumpy Bookstore owner
+//Problem Link: https://leetcode.com/problems/grumpy-bookstore-owner/
+
+
+//Code:
+
+class Solution {
+public:
+    int maxSatisfied(vector<int>& customers, vector<int>& grumpy, int minutes) {
+         int satisfied=0;
+         int n= customers.size();
+         for(int i=0;i<n;i++){
+            if(grumpy[i]==0)
+                satisfied+= customers[i];
+          }
+        int additionalsatisfied= 0; 
+        int left=0;
+        int right= minutes;
+        for(int i=0;i<minutes;i++){
+            if(grumpy[i]==1)
+            {
+                additionalsatisfied+= customers[i];
+            }
+        }
+        int maxx= additionalsatisfied;
+        while(right<n){
+            if(grumpy[right]==1){
+                additionalsatisfied+= customers[right]; /* If the satisfied customer found, then include in the given window or minute.*/
+            }
+            if(grumpy[left]==1){
+                additionalsatisfied-= customers[left]; /*If the unsatisfied customers found, then exclude from the window*/
+            }
+            maxx= max(maxx, additionalsatisfied);
+         left++;
+        right++;
+            }
+        
+        return satisfied+maxx;
+    }
+};

From af683e5abf01638b433e4262a66334cc3d2c2f87 Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <idevprakaash@gmail.com>
Date: Sat, 2 Oct 2021 01:28:55 +0530
Subject: [PATCH 171/203] Update CONTRIBUTING.md

---
 CONTRIBUTING.md | 26 +++++++++-----------------
 1 file changed, 9 insertions(+), 17 deletions(-)

diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index c4beecb..245621e 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1,31 +1,23 @@
+# Contribution Guide
 
-
-Please Read the Contribution Guidelines before making Pull Request
-
-# Contributing
-
-We love contributions from everyone.
-By participating in this project,
-you agree to abide by the thoughtbot [code of conduct].
+We love contributions from everyone and that's how we organize open source more authentic and inclusive.
+By participating in this project, you agree to abide by the thoughtbot [code of conduct].
 
 [code of conduct]: https://thoughtbot.com/open-source-code-of-conduct
 
-We expect everyone to follow the code of conduct
+We expect from everyone to follow the code of conduct
 anywhere in thoughtbot's project codebases,
 issue trackers, chatrooms, and mailing lists.
 
 # Pull Request Instructions
- - Instead of Creating a new Branch. Fork the Repo and Update Your contribution to the related files or Repo.
- - Try to add the Algorithm or Program in files respectively.
+ - Fork the Repo and create a new branch to update your contribution to the related files or Repo.
+ - Try to add plagfree algorithm or program in respective files or category.We appreciate plagfree contributions
  - You can add new content only **Related to C++ Programming**
- - Create a PR with subjective Title. This will help me to organize the content in better way.
- - Try to Update the .gitignore if you're adding different formats of content.
+ - Create a PR with meaningful header. This will help us to organize the content in better way.
+ - Try to update the .gitignore if you're adding different formats of content.
  - Create a PR :bowtie:
 
-## Contributing Code
-  - Fork the repo.
-
-  - Make sure the tests pass:
+## Contributing Co
 
 
 Make your change, with new passing tests. Follow the [style guide][style].

From 3e86866482114b568b825e5672cf3806741e49df Mon Sep 17 00:00:00 2001
From: jineshparakh <jineshparakh@hotmail.com>
Date: Sat, 2 Oct 2021 13:06:09 +0530
Subject: [PATCH 172/203] Added Rabin Miller Algorithm

---
 09- Number Theory/rabinMiller.cpp | 57 +++++++++++++++++++++++++++++++
 1 file changed, 57 insertions(+)
 create mode 100644 09- Number Theory/rabinMiller.cpp

diff --git a/09- Number Theory/rabinMiller.cpp b/09- Number Theory/rabinMiller.cpp
new file mode 100644
index 0000000..763ed15
--- /dev/null
+++ b/09- Number Theory/rabinMiller.cpp	
@@ -0,0 +1,57 @@
+#include<bits/stdc++.h>
+using namespace std;
+#define ll long long
+#define ld long double
+#define rep(i,a,b) for(ll i=a;i<b;i++)
+#define repp(i,a,b) for(ll i=a;i<=b;i++)
+#define rrep(i,a,b) for(ll i=a;i>=b;i--)
+#define endl "\n"
+
+ll k = 6;
+ll exp(ll x, ll y, ll p) {
+    ll res = 1;
+    while (y) {
+        if (y % 2)
+            res = (res * x % p) % p;
+        x = (x * x) % p;
+        y /= 2;
+    }
+    return res;
+}
+
+bool miller(ll d, ll n) {
+    ll a = 2 + rand() % (n - 4);
+    ll x = exp(a, d, n);
+    if (x == 1 || x == n - 1)
+        return true;
+    while (d != n - 1) {
+        x = (x * x) % n;
+        d = d * 2;
+        if (x == 1) return false;
+        if (x == n - 1) return true;
+    }
+    return false;
+}
+bool isPrime(ll n) {
+    if (n < 2 || n == 4) return false;
+    if (n <= 3) return true;
+    ll d = n - 1;
+    while (!(d & 1)) {
+        d /= 2;
+    }
+    rep(i, 0, k) {
+        if (!miller(d, n))
+            return false;
+    }
+    return true;
+}
+int main() {
+
+    ll n; cin >> n;
+    cout << isPrime(n);
+    return 0;
+    
+}
+
+
+

From 277cc4ff4aa818c038c6f960dd656cf5e8bdc759 Mon Sep 17 00:00:00 2001
From: thecoderebel <91749535+thecoderebel@users.noreply.github.com>
Date: Sat, 2 Oct 2021 20:04:42 +0530
Subject: [PATCH 173/203] Create #86-Partition-list.cpp

---
 ONLINE JUDGE/LeetCode/#86-Partition-list.cpp | 37 ++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#86-Partition-list.cpp

diff --git a/ONLINE JUDGE/LeetCode/#86-Partition-list.cpp b/ONLINE JUDGE/LeetCode/#86-Partition-list.cpp
new file mode 100644
index 0000000..653bde5
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#86-Partition-list.cpp	
@@ -0,0 +1,37 @@
+//Problem name: Partition List
+//Problem Link: https://leetcode.com/problems/partition-list/
+
+//Code
+
+class Solution {
+public:
+    ListNode* partition(ListNode* head, int x) {
+      
+      //Create two pointer initially at zeroth index.
+        ListNode*before= new ListNode(-1);
+        ListNode*after= new ListNode(-1);
+        ListNode*l1= before;
+        ListNode*l2= after;
+        ListNode*p= head;
+      
+      //Find the node which is less than the given index and replace it with the next node.
+      //Repeat the steps until the partition is not done.
+        while(p!=NULL){
+            if(p->val <x)
+            {
+                l1->next= p;
+                l1= l1->next;
+                p= p->next;
+            }
+            else
+            {
+                l2->next= p;
+                l2= l2->next;
+                p= p->next;
+            }
+        }
+        l1->next= after->next;
+        l2->next= NULL;
+        return before->next;
+    }
+};

From ee265db0f24fcc91c8df0c5c584b651e07c4886e Mon Sep 17 00:00:00 2001
From: theneek14 <neel.19je0558@mc.iitism.ac.in>
Date: Sat, 2 Oct 2021 21:41:42 +0530
Subject: [PATCH 174/203] Create 3sum_closest.cpp

---
 03-Arrays/3sum_closest.cpp | 42 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 03-Arrays/3sum_closest.cpp

diff --git a/03-Arrays/3sum_closest.cpp b/03-Arrays/3sum_closest.cpp
new file mode 100644
index 0000000..a75c8ed
--- /dev/null
+++ b/03-Arrays/3sum_closest.cpp
@@ -0,0 +1,42 @@
+/*
+Given an integer array nums of length n and an integer target, find three integers in nums such that the sum is closest to target.
+Return the sum of the three integers.
+Leetcode Problem Link: https://leetcode.com/problems/3sum-closest/
+My Leetcode Profile: theneek14
+*/
+
+//C++ Implementation 
+//My Original Code
+#include <bits/stdc++.h>
+using namespace std;
+
+int threeSumClosest(vector<int>& a, int t) {
+    sort(a.begin(),a.end());
+    int n=a.size(), ans, d=INT_MAX;
+    for(int i=0; i<n; i++){
+        int l=i+1, r=n-1;
+        while(r>l){
+            int x=a[l]+a[i]+a[r];
+            if(d>abs(x-t)) {d=abs(x-t); ans=x;}
+            if(x==t) return x;
+            if(x>t) r--;
+            if(x<t) l++;
+         }
+    }
+    return ans;
+}
+
+int main(){
+  //size of array
+  int n; cin>>n;
+  
+	vector<int> nums(n); //array of elements
+  
+  for(int i=0; i<n; i++){cin>>nums[i];}
+  
+  int target; cin>>target;
+  
+  cout<<"The sum of 3 integers, closest to target is: "<<threeSumClosest(nums, target);
+  
+	return 0;
+}

From 6fa300e61ca5cde7154fff603493f31c2c9092ce Mon Sep 17 00:00:00 2001
From: jineshparakh <jineshparakh@hotmail.com>
Date: Sat, 2 Oct 2021 22:39:20 +0530
Subject: [PATCH 175/203] Added Graph Theory Algorithms

---
 25-Graph Theory/bipartiteGraphTest.cpp  | 141 ++++++++++++++++++++++++
 25-Graph Theory/connectedComponents.cpp |  81 ++++++++++++++
 25-Graph Theory/dijkstras.cpp           | 133 ++++++++++++++++++++++
 3 files changed, 355 insertions(+)
 create mode 100644 25-Graph Theory/bipartiteGraphTest.cpp
 create mode 100644 25-Graph Theory/connectedComponents.cpp
 create mode 100644 25-Graph Theory/dijkstras.cpp

diff --git a/25-Graph Theory/bipartiteGraphTest.cpp b/25-Graph Theory/bipartiteGraphTest.cpp
new file mode 100644
index 0000000..fc8a59f
--- /dev/null
+++ b/25-Graph Theory/bipartiteGraphTest.cpp	
@@ -0,0 +1,141 @@
+#include<bits/stdc++.h>
+using namespace std;
+#define ll long long
+#define ld long double
+#define rep(i,a,b) for(ll i=a;i<b;i++)
+#define repp(i,a,b) for(ll i=a;i<=b;i++)
+#define rrep(i,a,b) for(ll i=a;i>=b;i--)
+#define endl "\n"
+#define deb(x) cerr << #x << "=" << x << endl
+#define debb(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
+#define mod ((ll)1e18)
+#define N ((ll)2e6)
+#define pb push_back
+#define in insert
+#define F first
+#define S second
+#define mp make_pair
+#define lb lower_bound
+#define ub upper_bound
+#define PI 3.1415926535897932384626
+#define all(x) x.begin(), x.end()
+#define rall(x) x.rbegin(), x.rend()
+#define speed ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
+#define test ll t; cin>>t; while(t--)
+typedef pair<ll, ll> pll;
+typedef vector<pll> vpll;
+ll dr[] = { -1, 1, 0, 0};
+ll dc[] = {0, 0, 1, -1};
+
+/*Functions*/
+ll gcd(ll a, ll b);
+ll exp(ll x, ll y, ll p);
+ll exp(ll x, ll y);
+void InverseofNumber();
+void InverseofFactorial();
+void factorial();
+ll Binomial(ll n, ll R);
+
+
+ll factorialNumInverse[N + 1];
+ll naturalNumInverse[N + 1];
+ll fact[N + 1];
+
+void fileIO() {
+#ifndef ONLINE_JUDGE
+    freopen("input.txt", "r", stdin);
+    freopen("output.txt", "w", stdout);
+#endif
+}
+ll n, m; //no of vertices and number of edges
+vector<ll> v[N]; //the graph representation
+ll vis[N]; //visited array
+ll color[N]; //color array
+bool dfs(ll x, ll c) {
+    vis[x] = 1;
+    color[x] = c;
+    for (auto i : v[x]) {
+        if (vis[i] == 0) {
+            if (dfs(i, c ^ 1) == false) //invert color
+                return false;
+        }
+        else {
+            if (color[x] == color[i])
+                return false;
+        }
+    }
+    return true;
+}
+int main() {
+    speed
+    // InverseofNumber(),InverseofFactorial(),factorial();
+    fileIO();
+    cin >> n >> m;
+    while (m--) {
+        ll xx, yy; cin >> xx >> yy;
+        v[xx].pb(yy);
+        v[yy].pb(xx);
+    }
+    ll ans = 0;
+    bool answer;
+    for (ll i = 1; i <= n; i++) {
+        if (!vis[i]) {
+            answer = dfs(i, 0); //dfs calls for unvisited nodes
+            if (!answer) {
+                cout << "NOT BIPARTITE" << endl;
+                exit(0);
+            }
+        }
+    }
+    cout << "BIPARTITE" << endl;
+
+    return 0;
+}
+
+
+/*All Functions*/
+ll gcd(ll a, ll b) {
+    if (b == 0)
+        return a;
+    return gcd(b, a % b);
+}
+
+ll exp(ll x, ll y, ll p) {
+    ll res = 1;
+    while (y) {
+        if (y % 2)
+            res = (res * x % p) % p;
+        x = (x * x) % p;
+        y /= 2;
+    }
+    return res;
+}
+ll exp(ll x, ll y) {
+    ll res = 1;
+    while (y) {
+        if (y % 2)
+            res = (res * x ) ;
+        x = (x * x) ;
+        y /= 2;
+    }
+    return res;
+}
+void InverseofNumber() {
+    naturalNumInverse[0] = naturalNumInverse[1] = 1;
+    for (ll i = 2; i <= N; i++)
+        naturalNumInverse[i] = naturalNumInverse[mod % i] * (mod - mod / i) % mod;
+}
+void InverseofFactorial() {
+    factorialNumInverse[0] = factorialNumInverse[1] = 1;
+    for (ll i = 2; i <= N; i++)
+        factorialNumInverse[i] = (naturalNumInverse[i] * factorialNumInverse[i - 1]) % mod;
+}
+void factorial() {
+    fact[0] = 1;
+    for (ll i = 1; i <= N; i++)
+        fact[i] = (fact[i - 1] * i) % mod;
+}
+ll Binomial(ll n, ll R) {
+    ll ans = ((fact[n] * factorialNumInverse[R]) % mod * (factorialNumInverse[n - R]) % mod) % mod;
+    return ans;
+}
diff --git a/25-Graph Theory/connectedComponents.cpp b/25-Graph Theory/connectedComponents.cpp
new file mode 100644
index 0000000..4aaa87b
--- /dev/null
+++ b/25-Graph Theory/connectedComponents.cpp	
@@ -0,0 +1,81 @@
+#include<bits/stdc++.h>
+// #warning x&1=0 if x is even and x&1=1 if x is odd
+// #include<ext/pb_ds/assoc_container.hpp>
+// #include <ext/pb_ds/tree_policy.hpp>
+// using namespace __gnu_pdbs;
+using namespace std;
+#define ll long long
+#define rep( i,  a,  b) for(ll i=a;i<b;i++)
+#define repp(i,a,b) for(ll i=a;i<=b;i++)
+#define rrep(i,a,b) for(ll i=a;i>=b;i--)
+#define ld long double
+#define endl "\n"
+#define mod ((ll)1e18)
+#define N ((ll)2e6+10)
+#define pb push_back
+#define in insert
+#define f first
+#define s second
+#define lb lower_bound
+#define ub upper_bound
+#define all(x) x.begin(), x.end()
+#define speed ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
+#define test ll t; cin>>t; while(t--)
+ll gcd(ll a, ll b) {if (b == 0)return a; return gcd(b, a % b);}
+ll exp(ll x, ll y, ll p) { ll res = 1; while (y) {if (y % 2) res = (res * x % p) % p; x = (x * x) % p; y /= 2; } return res;}
+ll exp(ll x, ll y) { ll res = 1; while (y) {if (y % 2) res = (res * x ) ; x = (x * x) ; y /= 2; } return res;}
+ll sv[1000000] = {0};
+ll factorialNumInverse[N + 1];
+ll naturalNumInverse[N + 1];
+ll fact[N + 1];
+void InverseofNumber() {naturalNumInverse[0] = naturalNumInverse[1] = 1; for (ll i = 2; i <= N; i++)naturalNumInverse[i] = naturalNumInverse[mod % i] * (mod - mod / i) % mod;}
+void InverseofFactorial() {factorialNumInverse[0] = factorialNumInverse[1] = 1; for (ll i = 2; i <= N; i++)factorialNumInverse[i] = (naturalNumInverse[i] * factorialNumInverse[i - 1]) % mod;}
+void factorial() {fact[0] = 1; for (ll i = 1; i <= N; i++) {fact[i] = (fact[i - 1] * i) % mod;}}
+ll Binomial(ll n, ll R) {ll ans = ((fact[n] * factorialNumInverse[R]) % mod * (factorialNumInverse[n - R]) % mod) % mod; return ans;}
+/*TOIENT FUNCTION*/ll phi(ll n) {ll ans = n; for (ll i = 2; i * i <= n; i++) {if (n % i == 0) {while (n % i == 0) n /= i; ans -= ans / i;}} if (n > 1) ans -= ans / n; return ans;}
+
+
+void fileIO() {
+#ifndef ONLINE_JUDGE
+    freopen("input.txt", "r", stdin);
+    freopen("output.txt", "w", stdout);
+#endif
+}
+ll n, k; ll vis[N] ;
+ll counter = 0;
+ll component[N];
+vector<ll> v[N];
+void dfs(ll at) {
+    if (vis[at] == 1) return;
+    vis[at] = 1;
+    component[at] = counter;
+    for (auto i : v[at]) {
+        dfs(i);
+    }
+}
+
+int main() {
+    speed
+    // InverseofNumber(),InverseofFactorial(),factorial();
+    fileIO();
+    cin >> n >> k;
+    rep(i, 0, k) {
+        ll xx, yy; cin >> xx >> yy;
+        v[xx].pb(yy);
+        v[yy].pb(xx);
+    }
+    fill(vis, vis + N, 0);
+    repp(i, 1, n) {
+        if (!vis[i]) {
+            counter++;
+            dfs(i);
+        }
+    }
+    repp(i, 0, n) {
+        cout << component[i] << " ";
+    }
+    cout << endl;
+
+
+    return 0;
+}
diff --git a/25-Graph Theory/dijkstras.cpp b/25-Graph Theory/dijkstras.cpp
new file mode 100644
index 0000000..fc3a30d
--- /dev/null
+++ b/25-Graph Theory/dijkstras.cpp	
@@ -0,0 +1,133 @@
+#include<bits/stdc++.h>
+using namespace std;
+#define ll long long
+#define ld long double
+#define rep(i,a,b) for(ll i=a;i<b;i++)
+#define repp(i,a,b) for(ll i=a;i<=b;i++)
+#define rrep(i,a,b) for(ll i=a;i>=b;i--)
+#define endl "\n"
+#define deb(x) cerr << #x << "=" << x << endl
+#define debb(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
+#define mod ((ll)1e18)
+#define N ((ll)2e6+10)
+#define pb push_back
+#define in insert
+#define F first
+#define S second
+#define lb lower_bound
+#define ub upper_bound
+#define PI 3.1415926535897932384626
+#define all(x) x.begin(), x.end()
+#define speed ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
+#define test ll t; cin>>t; while(t--)
+typedef pair<ll, ll> pll;
+typedef vector<pll> vpll;
+
+/*Functions*/
+ll gcd(ll a, ll b);
+ll exp(ll x, ll y, ll p);
+ll exp(ll x, ll y);
+void InverseofNumber();
+void InverseofFactorial();
+ll Binomial(ll n, ll R);
+
+
+ll factorialNumInverse[N + 1];
+ll naturalNumInverse[N + 1];
+ll fact[N + 1];
+
+void fileIO() {
+#ifndef ONLINE_JUDGE
+    freopen("input.txt", "r", stdin);
+    freopen("output.txt", "w", stdout);
+#endif
+}
+
+ll n, m;
+vector<pll> v[N];
+ll ids[N] = {0};
+ll dist[N] = {0};
+ll vis[N] = {0};
+
+int main() {
+    speed
+    // InverseofNumber(),InverseofFactorial(),factorial();
+    fileIO();
+
+    cin >> n >> m;
+    rep(i, 0, m) {
+        ll xx, yy, wt; cin >> xx >> yy >> wt;
+        v[xx].pb({yy, wt});
+    }
+    fill(dist, dist + N, mod);
+    dist[1] = 0;
+    multiset < pair < ll , ll > > s;
+    s.in({1, 0});
+    while (!s.empty()) {
+        pll x = *s.begin();
+        s.erase(s.begin());
+        vis[x.F] = 1;
+        for (auto i : v[x.F]) {
+            ll d = dist[x.F] + i.S;
+            if (d < dist[i.F]) {
+                dist[i.F] = d;
+                s.in({i.F, d});
+            }
+        }
+
+    }
+    repp(i, 1, n) {
+        cout << dist[i] << " ";
+    }
+    cout << endl;
+    return 0;
+}
+
+
+/*All Functions*/
+ll gcd(ll a, ll b) {
+    if (b == 0)
+        return a;
+    return gcd(b, a % b);
+}
+
+ll exp(ll x, ll y, ll p) {
+    ll res = 1;
+    while (y) {
+        if (y % 2)
+            res = (res * x % p) % p;
+        x = (x * x) % p;
+        y /= 2;
+    }
+    return res;
+}
+ll exp(ll x, ll y) {
+    ll res = 1;
+    while (y) {
+        if (y % 2)
+            res = (res * x ) ;
+        x = (x * x) ;
+        y /= 2;
+    }
+    return res;
+}
+void InverseofNumber() {
+    naturalNumInverse[0] = naturalNumInverse[1] = 1;
+    for (ll i = 2; i <= N; i++)
+        naturalNumInverse[i] = naturalNumInverse[mod % i] * (mod - mod / i) % mod;
+}
+void InverseofFactorial() {
+    factorialNumInverse[0] = factorialNumInverse[1] = 1;
+    for (ll i = 2; i <= N; i++)
+        factorialNumInverse[i] = (naturalNumInverse[i] * factorialNumInverse[i - 1]) % mod;
+}
+void factorial() {
+    fact[0] = 1;
+    for (ll i = 1; i <= N; i++)
+        fact[i] = (fact[i - 1] * i) % mod;
+}
+ll Binomial(ll n, ll R) {
+    ll ans = ((fact[n] * factorialNumInverse[R]) % mod * (factorialNumInverse[n - R]) % mod) % mod;
+    return ans;
+}
+

From 4183564227997c50eb29e1075978c72b255e5264 Mon Sep 17 00:00:00 2001
From: sarthakdelori <sarthakdelori10@gmail.com>
Date: Sun, 3 Oct 2021 14:23:11 +0530
Subject: [PATCH 176/203] create-sum-of-all-nodes.cpp

---
 18-Binary Tree/sum-of-all-nodes.cpp | 53 +++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)
 create mode 100644 18-Binary Tree/sum-of-all-nodes.cpp

diff --git a/18-Binary Tree/sum-of-all-nodes.cpp b/18-Binary Tree/sum-of-all-nodes.cpp
new file mode 100644
index 0000000..3ecabea
--- /dev/null
+++ b/18-Binary Tree/sum-of-all-nodes.cpp	
@@ -0,0 +1,53 @@
+/******************************************************************************
+
+program to find sum of all the nodes in a tree.
+the program is using level order traversal or BFS.
+
+*******************************************************************************/
+
+#include <iostream>
+#include <bits/stdc++.h>
+using namespace std;
+
+class Node {
+	public:
+	int data;
+	struct Node *left, *right;
+	Node(int x){
+	    data = x;
+	    left = right = NULL;
+	}
+};
+
+int main()
+{
+	Node* root = new Node(1);
+	root->left = new Node(2);
+	root->right = new Node(3);
+	root->left->left = new Node(4);
+	root->left->right = new Node(5);
+	root->right->left = new Node(6);
+	root->right->right = new Node(7);
+
+	int sum = 0;
+
+	queue<Node*> q;
+	q.push(root);
+
+	while (!q.empty()) {
+		Node* temp = q.front();
+		q.pop();
+	
+		sum += temp->data;
+
+		if (temp->left) {
+			q.push(temp->left);
+		}
+		if (temp->right) {
+			q.push(temp->right);
+		}
+	}
+	cout<<sum<<endl;
+	return 0;
+}
+

From 3fb33a8af142295c5cef6f1b8acb64b24bae045a Mon Sep 17 00:00:00 2001
From: Akshat jain <62347282+akshatjai258@users.noreply.github.com>
Date: Mon, 4 Oct 2021 11:40:34 +0530
Subject: [PATCH 177/203] Create Knapsack.cpp

---
 24- Dynamic Programming/Knapsack.cpp | 83 ++++++++++++++++++++++++++++
 1 file changed, 83 insertions(+)
 create mode 100644 24- Dynamic Programming/Knapsack.cpp

diff --git a/24- Dynamic Programming/Knapsack.cpp b/24- Dynamic Programming/Knapsack.cpp
new file mode 100644
index 0000000..2cff674
--- /dev/null
+++ b/24- Dynamic Programming/Knapsack.cpp	
@@ -0,0 +1,83 @@
+// Problem URL : https://atcoder.jp/contests/dp/tasks/dp_d
+
+#include<bits/stdc++.h>
+#include <ext/pb_ds/assoc_container.hpp>
+using namespace __gnu_pbds;
+using namespace std;
+#define ff              first
+#define ss              second
+#define int             long long
+#define pb              push_back
+#define mp              make_pair
+#define all(v)          v.begin(),v.end()
+#define pii             pair<int,int>
+#define vi              vector<int>
+#define mii             map<int,int>
+#define pqb             priority_queue<int>
+#define pqs             priority_queue<int,vi,greater<int> >
+#define setbits(x)      __builtin_popcountll(x)
+#define zrobits(x)      __builtin_ctzll(x)
+#define mod             1000000007
+#define inf             1e18
+#define ps(x,y)         fixed<<setprecision(y)<<x
+#define rep(i,a,b)      for(int i=a;i<b;i++)
+#define mem1(a)         memset(a,-1,sizeof(a))
+#define mem0(a)         memset(a,0,sizeof(a))
+mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
+
+template<typename T, typename T1>T amax(T &a, T1 b) {if (b > a)a = b; return a;}
+template<typename T, typename T1>T amin(T &a, T1 b) {if (b < a)a = b; return a;}
+template<typename T>
+using pbds = tree<T , null_type , less<T> , rb_tree_tag , tree_order_statistics_node_update>;
+const int N = 1e5 + 5;
+
+void solve() {
+    int n, W; cin >> n >> W;
+    vi w(n + 1), v(n + 1);
+
+    //take the weights and value as input
+    for (int i = 1; i <= n; i++) {
+        cin >> w[i] >> v[i];
+    }
+    vector<vector<int>>dp(n + 1, vi(W + 1));
+    // dp[i][j] = maximum value possible if we consider first 'i' items and total weight of those items not exceed 'j' 
+
+
+    // iterate over every item
+    for (int i = 1; i <= n; i++) {
+
+        for (int j = 0; j <= W; j++) {
+
+            // two possibilities - 
+
+            // either not take ith item in knapsack
+            dp[i][j] = dp[i - 1][j];
+
+            // take the ith item in knapsack
+            if (j - w[i] >= 0)
+                amax(dp[i][j], v[i] + dp[i - 1][j - w[i]]);
+        }
+    }
+
+    cout << dp[n][W] << endl;
+}
+
+
+int32_t main()
+{
+    ios_base::sync_with_stdio(false);
+    cin.tie(0); cout.tie(0);
+    //freopen("input.txt", "r", stdin);
+    //freopen("output.txt", "w", stdout);
+#ifdef SEIVE
+    seive();
+#endif
+#ifdef NCR
+    init();
+#endif
+    int t = 1;
+    // cin >> t;
+    while (t--) solve();
+    return 0;
+
+}

From 9af2de17976ce81a48258dfa79ce9d93887a6057 Mon Sep 17 00:00:00 2001
From: Bhasker Goel <bhasker2000goel@gmail.com>
Date: Tue, 5 Oct 2021 15:20:47 +0530
Subject: [PATCH 178/203] Added Mobius Function in Number Theory

---
 09- Number Theory/Mobius.cpp | 37 ++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 09- Number Theory/Mobius.cpp

diff --git a/09- Number Theory/Mobius.cpp b/09- Number Theory/Mobius.cpp
new file mode 100644
index 0000000..df8dee0
--- /dev/null
+++ b/09- Number Theory/Mobius.cpp	
@@ -0,0 +1,37 @@
+#include <bits/stdc++.h>
+
+using namespace std;
+
+vector<int> mobius(int n) {
+    vector<int> prime;
+    vector<int> mu(n + 1);
+    vector<bool> isComposite(n + 1, false);
+    mu[1] = 1;
+    for (int i = 2; i < n; ++i) {
+        if (!isComposite[i]) {
+            prime.push_back(i);
+            mu[i] = -1;
+        }
+        for (int j = 0; j < prime.size() && i * prime[j] <= n; ++j) {
+            isComposite[i * prime[j]] = true;
+            if (i % prime[j] == 0) {
+                mu[i * prime[j]] = 0;
+                break;
+            } else {
+                mu[i * prime[j]] = mu[i] * mu[prime[j]];
+            }
+        }
+    }
+    return mu;
+}
+
+signed main() {
+    int n;
+    cin >> n;
+    vector<int> mu = mobius(n);
+    for (int i : mu) {
+        cout << i << ' ';
+    }
+    cout << '\n';
+    return 0;
+}
\ No newline at end of file

From 950c3a3218f53268bd732a7b99daf654af043eca Mon Sep 17 00:00:00 2001
From: Akshat Saxena <76419575+tom635@users.noreply.github.com>
Date: Tue, 5 Oct 2021 20:00:55 +0530
Subject: [PATCH 179/203] Add files via upload

---
 25-Graph Theory/DFS.cpp | 43 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100644 25-Graph Theory/DFS.cpp

diff --git a/25-Graph Theory/DFS.cpp b/25-Graph Theory/DFS.cpp
new file mode 100644
index 0000000..84b8589
--- /dev/null
+++ b/25-Graph Theory/DFS.cpp	
@@ -0,0 +1,43 @@
+#include<bits/stdc++.h> 
+using namespace std; 
+
+void DFSRec(vector<int> adj[], int s, bool visited[]) 
+{ 	
+    visited[s]=true;
+    cout<< s <<" ";
+    
+    for(int u:adj[s]){
+        if(visited[u]==false)
+            DFSRec(adj,u,visited);
+    }
+}
+
+void DFS(vector<int> adj[], int V, int s){
+    bool visited[V]; 
+	for(int i = 0;i<V; i++) 
+		visited[i] = false;
+		
+    DFSRec(adj,s,visited);
+}
+
+void addEdge(vector<int> adj[], int u, int v){
+    adj[u].push_back(v);
+    adj[v].push_back(u);
+}
+
+int main() 
+{ 
+	int V=5;
+	vector<int> adj[V];
+	addEdge(adj,0,1); 
+	addEdge(adj,0,2); 
+	addEdge(adj,2,3); 
+	addEdge(adj,1,3); 
+	addEdge(adj,1,4);
+	addEdge(adj,3,4);
+
+	cout << "Following is Depth First Traversal: "<< endl; 
+	DFS(adj,V,0); 
+
+	return 0; 
+} 

From da963a448314a034f3961d1cc8810ece3bea5d0d Mon Sep 17 00:00:00 2001
From: Akshat Saxena <76419575+tom635@users.noreply.github.com>
Date: Tue, 5 Oct 2021 20:01:19 +0530
Subject: [PATCH 180/203] Add files via upload

---
 25-Graph Theory/BFS.cpp | 51 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)
 create mode 100644 25-Graph Theory/BFS.cpp

diff --git a/25-Graph Theory/BFS.cpp b/25-Graph Theory/BFS.cpp
new file mode 100644
index 0000000..1be5224
--- /dev/null
+++ b/25-Graph Theory/BFS.cpp	
@@ -0,0 +1,51 @@
+#include<bits/stdc++.h> 
+using namespace std; 
+
+void BFS(vector<int> adj[], int V, int s) 
+{ 
+	bool visited[V]; 
+	for(int i = 0; i < V; i++) 
+		visited[i] = false; 
+
+	queue<int>  q;
+	
+	visited[s] = true; 
+	q.push(s); 
+
+	while(q.empty()==false) 
+	{ 
+		int u = q.front(); 
+		q.pop();
+		cout << u << " "; 
+		 
+		for(int v:adj[u]){
+		    if(visited[v]==false){
+		        visited[v]=true;
+		        q.push(v);
+		    }
+		} 
+	} 
+} 
+
+void addEdge(vector<int> adj[], int u, int v){
+    adj[u].push_back(v);
+    adj[v].push_back(u);
+}
+
+int main() 
+{ 
+	int V=5;
+	vector<int> adj[V];
+	addEdge(adj,0,1); 
+	addEdge(adj,0,2); 
+	addEdge(adj,1,2); 
+	addEdge(adj,2,3); 
+	addEdge(adj,1,3);
+	addEdge(adj,3,4);
+	addEdge(adj,2,4);
+
+	cout << "Breadth First Traversal: "<< endl; 
+	BFS(adj,V,0); 
+
+	return 0; 
+} 

From edc16b5778ca92f92d2e89efb62fd3fbde499bdf Mon Sep 17 00:00:00 2001
From: Akshat Saxena <76419575+tom635@users.noreply.github.com>
Date: Tue, 5 Oct 2021 20:01:28 +0530
Subject: [PATCH 181/203] Add files via upload

---
 BFS.cpp | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)
 create mode 100644 BFS.cpp

diff --git a/BFS.cpp b/BFS.cpp
new file mode 100644
index 0000000..1be5224
--- /dev/null
+++ b/BFS.cpp
@@ -0,0 +1,51 @@
+#include<bits/stdc++.h> 
+using namespace std; 
+
+void BFS(vector<int> adj[], int V, int s) 
+{ 
+	bool visited[V]; 
+	for(int i = 0; i < V; i++) 
+		visited[i] = false; 
+
+	queue<int>  q;
+	
+	visited[s] = true; 
+	q.push(s); 
+
+	while(q.empty()==false) 
+	{ 
+		int u = q.front(); 
+		q.pop();
+		cout << u << " "; 
+		 
+		for(int v:adj[u]){
+		    if(visited[v]==false){
+		        visited[v]=true;
+		        q.push(v);
+		    }
+		} 
+	} 
+} 
+
+void addEdge(vector<int> adj[], int u, int v){
+    adj[u].push_back(v);
+    adj[v].push_back(u);
+}
+
+int main() 
+{ 
+	int V=5;
+	vector<int> adj[V];
+	addEdge(adj,0,1); 
+	addEdge(adj,0,2); 
+	addEdge(adj,1,2); 
+	addEdge(adj,2,3); 
+	addEdge(adj,1,3);
+	addEdge(adj,3,4);
+	addEdge(adj,2,4);
+
+	cout << "Breadth First Traversal: "<< endl; 
+	BFS(adj,V,0); 
+
+	return 0; 
+} 

From 52d11e167210cd1c848f54ccd790c5af3368872d Mon Sep 17 00:00:00 2001
From: Akshat Saxena <76419575+tom635@users.noreply.github.com>
Date: Tue, 5 Oct 2021 20:03:00 +0530
Subject: [PATCH 182/203] Create Cycle Detection in Directed Graph using
 BFS(Kahn's Algorithm).cpp

---
 ...cted Graph using BFS(Kahn's Algorithm).cpp | 63 +++++++++++++++++++
 1 file changed, 63 insertions(+)
 create mode 100644 25-Graph Theory/Cycle Detection in Directed Graph using BFS(Kahn's Algorithm).cpp

diff --git a/25-Graph Theory/Cycle Detection in Directed Graph using BFS(Kahn's Algorithm).cpp b/25-Graph Theory/Cycle Detection in Directed Graph using BFS(Kahn's Algorithm).cpp
new file mode 100644
index 0000000..25a8321
--- /dev/null
+++ b/25-Graph Theory/Cycle Detection in Directed Graph using BFS(Kahn's Algorithm).cpp	
@@ -0,0 +1,63 @@
+#include<bits/stdc++.h>
+using namespace std;
+
+class Solution {
+public:
+	bool isCyclic(int N, vector<int> adj[]) {
+        queue<int> q; 
+	    vector<int> indegree(N, 0); 
+	    for(int i = 0;i<N;i++) {
+	        for(auto it: adj[i]) {
+	            indegree[it]++; 
+	        }
+	    }
+	    
+	    for(int i = 0;i<N;i++) {
+	        if(indegree[i] == 0) {
+	            q.push(i); 
+	        }
+	    }
+	    int cnt = 0;
+	    while(!q.empty()) {
+	        int node = q.front(); 
+	        q.pop(); 
+	        cnt++; 
+	        for(auto it : adj[node]) {
+	            indegree[it]--;
+	            if(indegree[it] == 0) {
+	                q.push(it); 
+	            }
+	        }
+	    }
+	    if(cnt == N) return false; 
+	    return true; 
+	}
+};
+
+
+
+int main()
+{
+    
+    int t;
+    cin >> t;
+    while(t--)
+    {
+    	int V, E;
+    	cin >> V >> E;
+
+    	vector<int> adj[V];
+
+    	for(int i = 0; i < E; i++)
+    	{
+    		int u, v;
+    		cin >> u >> v;
+    		adj[u].push_back(v);
+    	}
+
+    	Solution obj;
+    	cout << obj.isCyclic(V, adj) << "\n";
+    }
+
+    return 0;
+}

From e45ef6959c741a2e8ed664ecdf1d2b26f3995651 Mon Sep 17 00:00:00 2001
From: Abhijeet Tiwari <abhijeet1862@gmail.com>
Date: Thu, 7 Oct 2021 13:43:41 +0530
Subject: [PATCH 183/203] kadens.cpp has been modified to add comments, example
 test cases and proper variable names for better understanding

---
 03-Arrays/kadens.cpp | 77 +++++++++++++++++++++++++++++++++++---------
 1 file changed, 62 insertions(+), 15 deletions(-)

diff --git a/03-Arrays/kadens.cpp b/03-Arrays/kadens.cpp
index 4858de7..879c26c 100644
--- a/03-Arrays/kadens.cpp
+++ b/03-Arrays/kadens.cpp
@@ -1,24 +1,71 @@
-#include<iostream>
+/**
+ * Our task is to take length of array and then the whole array as input from
+ * the user and then calculate the maximum contiguous subarray sum for the
+ * input array, using the kadane's algorithm.
+ *
+ * There can be a case that all the elements in the input array are negative.
+ * In that case, the least value among all elements is the maximum sum with
+ * subarray length = 1.
+ */
+
+#include <climits>	// for INT_MIN value
+#include <iostream> // for IO operations
 using namespace std;
-int main()
+
+/**
+ * max_suarray_sum function calculates the maximum contiguous sum for the given array.
+ */
+int max_subarray_sum(int arr[], int length)
 {
-	int cs=0;
-	int ms=0;
-	int n;cin>>n;
-	int a[100];
-	for(int i=0;i<n;i++)
+	int current_max = INT_MIN, current_sum = 0;
+	for (int i = 0; i < length; i++)
 	{
-		cin>>a[i];
-		
+		current_sum = current_sum + arr[i];
+		if (current_max < current_sum)
+		{
+			current_max = current_sum;
+		}
+
+		if (current_sum < 0)
+		{
+			current_sum = 0;
+		}
 	}
-	for(int i=0;i<n;i++)
+	return current_max;
+}
+
+/**
+* example test cases
+* {
+*    arr = {1, 2, 3, 4}
+*    maximum contiguos subarray sum = 1 + 2 + 3 + 4 = 10
+*    arr1 = {-1, -2, -4, -6, 7}
+*    maximum contiguos subarray sum = 7
+*    arr1 = {-1, -2, -4, -6, -7}
+*    maximum contiguos subarray sum = -1
+* }
+*/
+
+// main function
+int main()
+{
+	// code for accepting array from user starts
+
+	int n; // variable for length of input array
+	cout << "Enter length of the array: ";
+	cin >> n;
+	int arr[n]; // array to store the input array
+
+	for (int i = 0; i < n; i++) //taking elements of the array
 	{
-		cs= cs+a[i];
-		if(cs<0)
+
 		{
-			cs=0;
+			cin >> arr[i];
 		}
-		ms= max(ms,cs);
 	}
-	cout<<"MAXIMUM SUM IS:"<<ms<<endl;
+	// code for accepting array from user ends
+	int max_sum = max_subarray_sum(arr, n); // max_sum stores the maximum contiguous subarray sum
+	cout << "Maximum contiguous sum for this array is : " << max_sum << endl;
+
+	return 0;
 }

From 153bf1987c8fd09a91ed23d3404cf85cca7159a3 Mon Sep 17 00:00:00 2001
From: Prathamesh Kurunkar <kurunkarprathamesh7@gmail.com>
Date: Sat, 9 Oct 2021 22:52:29 +0530
Subject: [PATCH 184/203] feat: added AllUniques program in Strings

---
 String/AllUniques.cpp | 46 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
 create mode 100644 String/AllUniques.cpp

diff --git a/String/AllUniques.cpp b/String/AllUniques.cpp
new file mode 100644
index 0000000..b7e1b6f
--- /dev/null
+++ b/String/AllUniques.cpp
@@ -0,0 +1,46 @@
+// An algorithm to check if a string has all unique characters.
+// Sample Input-1: Hello
+// Sample Output-2: All Characters are not Unique
+
+// Sample Input-1: World
+// Sample Output-2: All Characters are Unique
+
+
+#include<bits/stdc++.h>
+using namespace std;
+
+// time complexity = O(n)
+// 128-character alphabet set
+bool isAllUnique(string st)
+{
+    if(st.length()>128)
+    return false;
+
+    // initialize vector to zero flag
+    vector<bool> char_set(128,0);
+    int val;
+    for (int i = 0; i < st.length(); i++)
+    {
+        val = st.at(i);
+        if(char_set[val])
+        {
+            // already found this character
+            return false;
+        }
+
+        char_set[val] = true;
+    }
+    return true;
+}
+
+int main()
+{
+    string st;
+    getline(cin,st);
+    if(isAllUnique(st)){
+        cout<<"All Characters are Unique"<<endl;
+    }else{
+        cout<<"All Characters are not Unique"<<endl;
+    }
+    return 0;
+}
\ No newline at end of file

From d0d5ba89e8e0b0370a880c36b4ce339f6c9c87a4 Mon Sep 17 00:00:00 2001
From: Luciano Santos <luciano_z7@hotmail.com>
Date: Sun, 10 Oct 2021 20:27:24 -0300
Subject: [PATCH 185/203] Adding Longest Increasing Subsequence algorithm

---
 .../longestIncreasingSubsequence.cpp          | 43 +++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100644 24- Dynamic Programming/longestIncreasingSubsequence.cpp

diff --git a/24- Dynamic Programming/longestIncreasingSubsequence.cpp b/24- Dynamic Programming/longestIncreasingSubsequence.cpp
new file mode 100644
index 0000000..7b73a7e
--- /dev/null
+++ b/24- Dynamic Programming/longestIncreasingSubsequence.cpp	
@@ -0,0 +1,43 @@
+#include <iostream>
+using namespace std;
+ 
+int _lis(int arr[], int n, int* max_ref)
+{
+     
+    if (n == 1)
+        return 1;
+
+    int res, max_ending_here = 1;
+ 
+    for(int i = 1; i < n; i++)
+    {
+        res = _lis(arr, i, max_ref);
+        if (arr[i - 1] < arr[n - 1] &&
+              res + 1 > max_ending_here)
+            max_ending_here = res + 1;
+    }
+ 
+    if (*max_ref < max_ending_here)
+        *max_ref = max_ending_here;
+ 
+    return max_ending_here;
+}
+ 
+int lis(int arr[], int n)
+{
+     
+    int max = 1;
+ 
+    _lis(arr, n, &max);
+ 
+    return max;
+}
+ 
+int main()
+{
+    int arr[] = { 10, 22, 9, 33, 21, 50, 41, 60 };
+    int n = sizeof(arr) / sizeof(arr[0]);
+     
+    cout << "Length of lis is " << lis(arr, n) << "\n";
+    return 0;
+}
\ No newline at end of file

From 3a74c459ff03f6792cce503d5b4b7112f9677459 Mon Sep 17 00:00:00 2001
From: Luciano Santos <luciano_z7@hotmail.com>
Date: Mon, 11 Oct 2021 13:26:42 -0300
Subject: [PATCH 186/203] Adding description for LIS problem

---
 24- Dynamic Programming/longestIncreasingSubsequence.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/24- Dynamic Programming/longestIncreasingSubsequence.cpp b/24- Dynamic Programming/longestIncreasingSubsequence.cpp
index 7b73a7e..eae4903 100644
--- a/24- Dynamic Programming/longestIncreasingSubsequence.cpp	
+++ b/24- Dynamic Programming/longestIncreasingSubsequence.cpp	
@@ -1,5 +1,11 @@
 #include <iostream>
 using namespace std;
+
+/*
+    The longest increasing subsequence problem is to find a subsequence of a given sequence in which 
+    he subsequence's elements are in sorted order, lowest to highest, and in which the subsequence is 
+    as long as possible.
+*/
  
 int _lis(int arr[], int n, int* max_ref)
 {

From 905d5ab508e5fffdc6ade127d95ceba86fb9a824 Mon Sep 17 00:00:00 2001
From: FranciscoHeronildo <heronildo.2010@hotmail.com>
Date: Mon, 11 Oct 2021 18:49:11 -0300
Subject: [PATCH 187/203] Adding Sequence Alignment

---
 24- Dynamic Programming/SequenceAlignment.cpp | 129 ++++++++++++++++++
 1 file changed, 129 insertions(+)
 create mode 100644 24- Dynamic Programming/SequenceAlignment.cpp

diff --git a/24- Dynamic Programming/SequenceAlignment.cpp b/24- Dynamic Programming/SequenceAlignment.cpp
new file mode 100644
index 0000000..acf3f02
--- /dev/null
+++ b/24- Dynamic Programming/SequenceAlignment.cpp	
@@ -0,0 +1,129 @@
+#include <bits/stdc++.h>
+using namespace std;
+
+// The Sequence Alignment problem is one of the fundamental problems of Biological Sciences,
+// aimed at finding the similarity of two amino-acid sequences. Comparing amino-acids is of prime importance to humans,
+// since it gives vital information on evolution and development. The feasible solution is to introduce gaps into the strings, so as to equalise the lengths.
+// Since it can be easily proved that the addition of extra gaps after equalising the lengths will only lead to increment of penalty.
+
+
+void getMinimumPenalty(string x, string y, int pxy, int pgap)
+{
+	int i, j;
+
+	int m = x.length();
+	int n = y.length();
+    	
+	int dp[m+1][n+1] = {0};
+
+	for (i = 0; i <= (n+m); i++)
+	{
+		dp[i][0] = i * pgap;
+		dp[0][i] = i * pgap;
+	}
+
+	for (i = 1; i <= m; i++)
+	{
+		for (j = 1; j <= n; j++)
+		{
+			if (x[i - 1] == y[j - 1])
+			{
+				dp[i][j] = dp[i - 1][j - 1];
+			}
+			else
+			{
+				dp[i][j] = min({dp[i - 1][j - 1] + pxy ,
+								dp[i - 1][j] + pgap ,
+								dp[i][j - 1] + pgap });
+			}
+		}
+	}
+
+	int l = n + m;
+	
+	i = m; j = n;
+	
+	int xpos = l;
+	int ypos = l;
+
+	int xans[l+1], yans[l+1];
+	
+	while ( !(i == 0 || j == 0))
+	{
+		if (x[i - 1] == y[j - 1])
+		{
+			xans[xpos--] = (int)x[i - 1];
+			yans[ypos--] = (int)y[j - 1];
+			i--; j--;
+		}
+		else if (dp[i - 1][j - 1] + pxy == dp[i][j])
+		{
+			xans[xpos--] = (int)x[i - 1];
+			yans[ypos--] = (int)y[j - 1];
+			i--; j--;
+		}
+		else if (dp[i - 1][j] + pgap == dp[i][j])
+		{
+			xans[xpos--] = (int)x[i - 1];
+			yans[ypos--] = (int)'_';
+			i--;
+		}
+		else if (dp[i][j - 1] + pgap == dp[i][j])
+		{
+			xans[xpos--] = (int)'_';
+			yans[ypos--] = (int)y[j - 1];
+			j--;
+		}
+	}
+	while (xpos > 0)
+	{
+		if (i > 0) xans[xpos--] = (int)x[--i];
+		else xans[xpos--] = (int)'_';
+	}
+	while (ypos > 0)
+	{
+		if (j > 0) yans[ypos--] = (int)y[--j];
+		else yans[ypos--] = (int)'_';
+	}
+
+    // Since we have assumed the answer to be n+m long,
+    // we need to remove the extra gaps in the starting
+    // id represents the index from which the arrays
+    // xans, yans are useful
+	int id = 1;
+	for (i = l; i >= 1; i--)
+	{
+		if ((char)yans[i] == '_' && (char)xans[i] == '_')
+		{
+			id = i + 1;
+			break;
+		}
+	}
+
+	cout << "Minimum Penalty in aligning the genes = ";
+	cout << dp[m][n] << "\n";
+	cout << "The aligned genes are :\n";
+	for (i = id; i <= l; i++)
+	{
+		cout<<(char)xans[i];
+	}
+	cout << "\n";
+	for (i = id; i <= l; i++)
+	{
+		cout << (char)yans[i];
+	}
+	return;
+}
+
+int main(){
+
+	string gene1 = "AGGGCT";
+	string gene2 = "AGGCA";
+	
+	int misMatchPenalty = 3;
+	int gapPenalty = 2;
+
+	getMinimumPenalty(gene1, gene2,
+		misMatchPenalty, gapPenalty);
+	return 0;
+}

From 715afa8e144d3adb8986664aa9620145f140b710 Mon Sep 17 00:00:00 2001
From: anubhav300 <86737429+anubhav300@users.noreply.github.com>
Date: Tue, 12 Oct 2021 21:08:58 +0530
Subject: [PATCH 188/203] inversions_in_array

finding the number of inversions in an array using merge sort(O(nlogn)) as well as intuitive solution(O(n^2))
---
 04-Sorting/inversions.cpp | 87 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 87 insertions(+)
 create mode 100644 04-Sorting/inversions.cpp

diff --git a/04-Sorting/inversions.cpp b/04-Sorting/inversions.cpp
new file mode 100644
index 0000000..5f18ed4
--- /dev/null
+++ b/04-Sorting/inversions.cpp
@@ -0,0 +1,87 @@
+#include "bits/stdc++.h"
+using namespace std;
+void printArr(int arr[], int n,string s="\n"){
+	if(s==" "){
+		for(int i=0;i<n;i++){
+		cout<<arr[i]<<" ";
+	}
+	cout<<endl;	
+	}
+	else{
+		for(int i=0;i<n;i++){
+		cout<<arr[i]<<'\n';
+	}
+	}
+	}
+int merge(int left[], int right[], int arr[], int leftLength, int rightLength){
+	int i=0,j=0,k = 0;
+	int inversions = 0 ;
+	while(i< leftLength && j<rightLength){
+		if(left[i]<=right[j]){
+			arr[k]= left[i];
+			i++;
+			k++;
+		}
+		else {
+			arr[k] = right[j];
+			j++;
+			k++;
+			inversions += leftLength - i;
+		}
+	}
+	while(i<leftLength){
+		arr[k] = left[i];
+		i++;
+		k++;
+		//inversions += rightLength;
+
+	}
+	while(j<rightLength){
+		arr[k] = right[j];
+		j++;
+		k++;
+	}
+	return inversions;
+}
+int mergeSort(int arr[], int n){
+	int mid = n/2;
+	if(n<2){
+		return 0;
+	}
+	int left[mid];
+	int right[n-mid];
+	
+	for(int i = 0 ; i<mid;i++){
+		left[i] = arr[i];
+	}
+	//printArr(left, mid," ");
+	int i = 0 ;
+	for(int j = mid;j<n;j++){
+		right[i] = arr[j];
+		i++;
+	}
+	//printArr(right, n-mid," ");
+	int x = mergeSort(left, mid);
+	int y = mergeSort(right, n- mid);
+	int z = merge(left, right, arr,mid, n- mid);
+	
+	return x+y+z;
+		
+}
+int inversions(int arr[], int n){
+	int d = 0;
+	for(int i = 0 ;i< n;i++){
+		for(int j = i+1;j<n;j++){
+			if(arr[i]>arr[j]){
+				d++;
+			}
+		}
+	}
+
+return d;}
+int main(){
+	int arr[8] = {2,1,4,6,7,5,3,8};
+	cout<< "Inversions are:"<< inversions(arr,8)<<endl;
+	cout<< "Inversions output:"<< mergeSort(arr,8)<<endl; 	
+	return 0;
+}
\ No newline at end of file

From a5e5f4d8e054c9cabd4259b3015ac893f756c97e Mon Sep 17 00:00:00 2001
From: anubhav300 <86737429+anubhav300@users.noreply.github.com>
Date: Wed, 27 Oct 2021 08:50:42 +0530
Subject: [PATCH 189/203] Updated

Added problem and comments in the code
---
 04-Sorting/inversions.cpp | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/04-Sorting/inversions.cpp b/04-Sorting/inversions.cpp
index 5f18ed4..7fce458 100644
--- a/04-Sorting/inversions.cpp
+++ b/04-Sorting/inversions.cpp
@@ -1,3 +1,8 @@
+/*
+Count Inversions in an array using both the O(n^2) solution and using the optimised O(nlogn) solution. 
+Inversion Count for an array indicates – how far (or close) the array is from being sorted. If the array is already sorted, then the inversion count is 0, but if the array is sorted in the reverse order, the inversion count is the maximum. 
+Formally speaking, two elements a[i] and a[j] form an inversion if a[i] > a[j] and i < j 
+*/
 #include "bits/stdc++.h"
 using namespace std;
 void printArr(int arr[], int n,string s="\n"){
@@ -14,6 +19,7 @@ void printArr(int arr[], int n,string s="\n"){
 	}
 	}
 int merge(int left[], int right[], int arr[], int leftLength, int rightLength){
+	//the helper function which helps to merge two arrays, left and right
 	int i=0,j=0,k = 0;
 	int inversions = 0 ;
 	while(i< leftLength && j<rightLength){
@@ -44,6 +50,7 @@ int merge(int left[], int right[], int arr[], int leftLength, int rightLength){
 	return inversions;
 }
 int mergeSort(int arr[], int n){
+	//the main merge sort function takes in array and the number of elements in the array
 	int mid = n/2;
 	if(n<2){
 		return 0;
@@ -84,4 +91,4 @@ int main(){
 	cout<< "Inversions are:"<< inversions(arr,8)<<endl;
 	cout<< "Inversions output:"<< mergeSort(arr,8)<<endl; 	
 	return 0;
-}
\ No newline at end of file
+}

From da8f8a31bab5f12a99afae5104f147c6ea052067 Mon Sep 17 00:00:00 2001
From: thecoderebel <91749535+thecoderebel@users.noreply.github.com>
Date: Sat, 30 Oct 2021 18:45:29 +0530
Subject: [PATCH 190/203] Create #34- swap-nodes.cpp

---
 ONLINE JUDGE/LeetCode/#34- swap-nodes.cpp | 29 +++++++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 ONLINE JUDGE/LeetCode/#34- swap-nodes.cpp

diff --git a/ONLINE JUDGE/LeetCode/#34- swap-nodes.cpp b/ONLINE JUDGE/LeetCode/#34- swap-nodes.cpp
new file mode 100644
index 0000000..051fe72
--- /dev/null
+++ b/ONLINE JUDGE/LeetCode/#34- swap-nodes.cpp	
@@ -0,0 +1,29 @@
+//Problem statement
+
+//Given a linked list, swap every two adjacent nodes and return its head. You must solve the problem without modifying the values in the list's nodes (i.e., only nodes themselves may be changed.)
+//Example-
+
+//Input: 1->2->3->4
+//Output: 2->1->4->3
+
+//Solution
+
+class Solution {
+public:
+    ListNode* swapPairs(ListNode* head) {
+        if(!head or !head->next){
+            return head;
+        }
+      //Check and replace the node to its next node
+        ListNode*a= head;
+        ListNode*b= head;
+        b= a->next;
+        a->next= b->next;
+        b->next= a;
+        head= b;
+      //Swap the node
+        a->next= swapPairs(a->next);
+        return head;
+        
+    }
+};

From 895b3534b206c1a089cc29ea51744dcc0e2beb70 Mon Sep 17 00:00:00 2001
From: devanshigarg01 <75984570+devanshigarg01@users.noreply.github.com>
Date: Sat, 30 Oct 2021 19:07:21 +0530
Subject: [PATCH 191/203] Jump Search

---
 05-Searching/JumpSearch.cpp | 47 +++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)
 create mode 100644 05-Searching/JumpSearch.cpp

diff --git a/05-Searching/JumpSearch.cpp b/05-Searching/JumpSearch.cpp
new file mode 100644
index 0000000..8e6a69d
--- /dev/null
+++ b/05-Searching/JumpSearch.cpp
@@ -0,0 +1,47 @@
+#include<iostream>
+#include<cmath>
+using namespace std;
+
+int jumpSearch( int arr[], int L, int key)
+{
+int step = sqrt(L);
+int left = 0;
+int right = step;
+
+while(arr[right]<= key && right <= L)
+{
+    left = right;
+    right = right + step;
+
+    if( right > L-1)
+{
+    right = L-1;
+}
+}
+
+
+for( int i = left; i <= right; i++)
+{
+   if(arr[i] == key)
+   {
+       return i;
+   }
+}
+return -1;
+}
+
+int main()
+{
+    int arr[] = {5,10,15,20,25,30,35,40,45,50,55,60,65,70};
+    int L = sizeof(arr)/ sizeof(arr[0]);
+
+    cout<<"Enter the number to be searched"<<endl;
+    
+    int key;
+    cin>> key;
+
+    int result = jumpSearch( arr , L, key);
+
+    cout<< result;
+    return 0;
+}

From f6a786bab4accc07f1d709ed948144cfdc0dcf3e Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <idevprakaash@gmail.com>
Date: Fri, 30 Sep 2022 23:20:22 +0530
Subject: [PATCH 192/203] Update README.md

---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 14e3d67..65c900a 100644
--- a/README.md
+++ b/README.md
@@ -48,7 +48,7 @@ Once you create your PR, it will be reviewed and hopefully merged quickly!
 Congrats, you're officially a Contributor!
 
  
- ## 🎉Contributors
+ ## 🎉Contributors of 2021
  
 Big shoutout to all the contributors who have put their efforts to make it big!! 🥇
 

From 98d303f9256c8028bc6e62fe6dd6981b1353ef22 Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <idevprakaash@gmail.com>
Date: Fri, 30 Sep 2022 23:20:49 +0530
Subject: [PATCH 193/203] Update README.md

---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 65c900a..f422a87 100644
--- a/README.md
+++ b/README.md
@@ -48,7 +48,7 @@ Once you create your PR, it will be reviewed and hopefully merged quickly!
 Congrats, you're officially a Contributor!
 
  
- ## 🎉Contributors of 2021
+ ## 🎉 Contributors
  
 Big shoutout to all the contributors who have put their efforts to make it big!! 🥇
 

From d8254c6f52abd4fa6f12870403c9993d05989d2b Mon Sep 17 00:00:00 2001
From: Abhijeet Tiwari <abhijeet1862@gmail.com>
Date: Wed, 5 Oct 2022 05:58:08 +0530
Subject: [PATCH 194/203] longestCommonSubstring.cpp created

---
 .../longestCommonSubstring.cpp                | 56 +++++++++++++++++++
 1 file changed, 56 insertions(+)
 create mode 100644 24- Dynamic Programming/longestCommonSubstring.cpp

diff --git a/24- Dynamic Programming/longestCommonSubstring.cpp b/24- Dynamic Programming/longestCommonSubstring.cpp
new file mode 100644
index 0000000..59519e2
--- /dev/null
+++ b/24- Dynamic Programming/longestCommonSubstring.cpp	
@@ -0,0 +1,56 @@
+// Problem : A substring of a string is a subsequence in which all the characters are consecutive.Given two strings,
+// we need to find the longest common substring.
+
+// Approach :
+
+// We are creating a 2d dp array corresponding to the dimensions of the array. Now if the characters for a pair of
+// i, j are not equal, that show that they can be included in the final answer and hence they are discarded.
+// Else, we take a look at dp[i-1][j-1] if the continuity is maintained the we can find a continous equal substring
+// or not.
+
+#include <bits/stdc++.h>
+using namespace std;
+
+int lcs(string &s1, string &s2)
+{
+    int n = s1.size();
+    int m = s2.size();
+    vector<vector<int>> dp(n + 1, vector<int>(m + 1, 0));
+    int ans = 0;
+    for (int i = 1; i <= n; i++)
+    {
+        for (int j = 1; j <= m; j++)
+        {
+            if (s1[i - 1] == s2[j - 1])
+            {
+                // looking if just previous characters are also equal or not
+                int val = 1 + dp[i - 1][j - 1];
+                dp[i][j] = val;
+                ans = max(ans, val);
+            }
+            else
+            {
+                // not a part of equal substring, hence 0
+                dp[i][j] = 0;
+            }
+        }
+    }
+    return ans;
+}
+
+int main()
+{
+    string s1;
+    string s2;
+    cin >> s1 >> s2;
+    cout << "The Length of Longest Common Substring is " << lcs(s1, s2);
+}
+
+// Sample Inputs
+
+// abcjklp
+// acjkp
+
+// Corresponding Outputs
+
+// 3
\ No newline at end of file

From 436223f5ccff9d96d80b69063b71ba2e1bcb16f3 Mon Sep 17 00:00:00 2001
From: Abhijeet Tiwari <abhijeet1862@gmail.com>
Date: Wed, 5 Oct 2022 06:11:03 +0530
Subject: [PATCH 195/203] minFallingPathSumTriangle.cpp created

---
 .../minFallingPathSumTriangle.cpp             | 77 +++++++++++++++++++
 1 file changed, 77 insertions(+)
 create mode 100644 24- Dynamic Programming/minFallingPathSumTriangle.cpp

diff --git a/24- Dynamic Programming/minFallingPathSumTriangle.cpp b/24- Dynamic Programming/minFallingPathSumTriangle.cpp
new file mode 100644
index 0000000..d3b1fb9
--- /dev/null
+++ b/24- Dynamic Programming/minFallingPathSumTriangle.cpp	
@@ -0,0 +1,77 @@
+// Problem : Given a triangle array, return the minimum path sum from top to bottom. For each step, you may move to an
+// adjacent number of the row below.More formally, if you are on index i on the current row, you may move to either
+// index i or index i + 1 on the next row.
+
+#include <bits/stdc++.h>
+using namespace std;
+
+int minimumTotal(vector<vector<int>> &triangle)
+{
+    int n = triangle.size();
+    vector<vector<int>> dp(n);
+    for (int i = 0; i < n; i++)
+    {
+        for (int j = 0; j < triangle[i].size(); j++)
+        {
+            if (i == 0 and j == 0)
+            {
+                // very first cell
+                dp[i].push_back(triangle[i][j]);
+            }
+            else if (j == 0)
+            {
+                // we can jump to this cell by one way(⬇️)
+                dp[i].push_back(dp[i - 1][j] + triangle[i][j]);
+            }
+            else if (j == (triangle[i].size() - 1))
+            {
+                // we can jump to this cell by one way(↘️)
+                dp[i].push_back(dp[i - 1][j - 1] + triangle[i][j]);
+            }
+            else
+            {
+                // we can jump to this cell by two ways(⬇️ and ↘️)
+                dp[i].push_back(min(dp[i - 1][j], dp[i - 1][j - 1]) + triangle[i][j]);
+            }
+        }
+    }
+    // returning the minimum out of all calculated sums
+    return *min_element(dp[n - 1].begin(), dp[n - 1].end());
+}
+int main()
+{
+    int n;
+    cin >> n;
+    vector<vector<int>> triangle(n);
+    for (int i = 0; i < n; i++)
+    {
+        for (int j = 0; j <= i; j++)
+        {
+            int x;
+            cin >> x;
+            triangle[i].push_back(x);
+        }
+    }
+    cout << minimumTotal(triangle);
+}
+
+// Sample Inputs
+
+// Sample Inputs
+
+// Sample Inputs
+
+// 4
+// 2
+// 3 4
+// 6 5 7
+// 4 1 8 3
+
+// 1
+// -10
+
+// Corresponding Outputs
+
+// 11
+
+// -10
\ No newline at end of file

From 40b642a858fb56fc75c91533019a1830fe589d4c Mon Sep 17 00:00:00 2001
From: Abhijeet Tiwari <abhijeet1862@gmail.com>
Date: Wed, 5 Oct 2022 06:13:11 +0530
Subject: [PATCH 196/203] ninjaAndHisFriends.cpp created

---
 .../ninjaAndHisFriends.cpp                    | 125 ++++++++++++++++++
 1 file changed, 125 insertions(+)
 create mode 100644 24- Dynamic Programming/ninjaAndHisFriends.cpp

diff --git a/24- Dynamic Programming/ninjaAndHisFriends.cpp b/24- Dynamic Programming/ninjaAndHisFriends.cpp
new file mode 100644
index 0000000..53d990f
--- /dev/null
+++ b/24- Dynamic Programming/ninjaAndHisFriends.cpp	
@@ -0,0 +1,125 @@
+// Problem(3-D DP) : We are given an ‘N *M’ matrix.Every cell of the matrix has some chocolates on it, mat[i][j] gives us the
+// number of chocolates.We have two friends ‘Alice’ and ‘Bob’.initially, Alice is standing on the cell(0, 0) and Bob is standing
+// on the cell(0, M - 1).Both of them can move only to the cells below them in these three directions : to the bottom cell(↓),
+// to the bottom - right cell(↘), or to the bottom - left cell(↙). When Alica and Bob visit a cell, they take all the chocolates
+// from that cell with them. It can happen that they visit the same cell, in that case, the chocolates need to be considered only
+// once. They cannot go out of the boundary of the given matrix, we need to return the maximum number of chocolates that Bob and
+// Alice can together collect.
+
+#include <bits/stdc++.h>
+using namespace std;
+
+int f(int i, int j1, int j2, vector<vector<int>> &grid, int n, int m, vector<vector<vector<int>>> &dp)
+{
+    if (i == n)
+    {
+        return 0;
+    }
+    if (dp[i][j1][j2] != -1)
+    {
+        return dp[i][j1][j2];
+    }
+    int mx = INT_MIN;
+    // if Alice can move to the left column in the row below
+    if (((j1 - 1) >= 0))
+    {
+        // if Bob can move to the same column in the row below
+        mx = max(mx, f(i + 1, j1 - 1, j2, grid, n, m, dp));
+        // if Bob can move to the left column in the row below
+        if ((j2 - 1) >= 0)
+        {
+            mx = max(mx, f(i + 1, j1 - 1, j2 - 1, grid, n, m, dp));
+        }
+        // if Bob can move to the right column in the row below
+        if ((j2 + 1) < m)
+        {
+            mx = max(mx, f(i + 1, j1 - 1, j2 + 1, grid, n, m, dp));
+        }
+    }
+    // if Alice can move to the same column in the row below
+    // if Bob can move to the same column in the row below
+    mx = max(mx, f(i + 1, j1, j2, grid, n, m, dp));
+    // if Bob can move to the left column in the row below
+    if ((j2 - 1) >= 0)
+    {
+        mx = max(mx, f(i + 1, j1, j2 - 1, grid, n, m, dp));
+    }
+    // if Bob can move to the right column in the row below
+    if ((j2 + 1) < m)
+    {
+        mx = max(mx, f(i + 1, j1, j2 + 1, grid, n, m, dp));
+    }
+    // if Alice can move to the right column in the row below
+    if (((j1 + 1) < m))
+    {
+        // if Bob can move to the same column in the row below
+        mx = max(mx, f(i + 1, j1 + 1, j2, grid, n, m, dp));
+        // if Bob can move to the left column in the row below
+        if ((j2 - 1) >= 0)
+        {
+            mx = max(mx, f(i + 1, j1 + 1, j2 - 1, grid, n, m, dp));
+        }
+        // if Bob can move to the right column in the row below
+        if ((j2 + 1) < m)
+        {
+            mx = max(mx, f(i + 1, j1 + 1, j2 + 1, grid, n, m, dp));
+        }
+    }
+    if (j1 == j2)
+    {
+        // if same cell for both alice and bob, count chocolates only once
+        return dp[i][j1][j2] = (mx + grid[i][j1]);
+    }
+    else
+    {
+        return dp[i][j1][j2] = (mx + grid[i][j1] + grid[i][j2]);
+    }
+}
+
+int maximumChocolates(int r, int c, vector<vector<int>> &grid)
+{
+    vector<vector<vector<int>>> dp(r, vector<vector<int>>(c, vector<int>(c)));
+    for (int i = 0; i < r; i++)
+    {
+        for (int j = 0; j < c; j++)
+        {
+            for (int k = 0; k < c; k++)
+            {
+                dp[i][j][k] = -1;
+            }
+        }
+    }
+    return f(0, 0, c - 1, grid, r, c, dp);
+}
+
+int main()
+{
+    int r, c;
+    cin >> r >> c;
+    vector<vector<int>> grid(r, vector<int>(c));
+    for (int i = 0; i < r; i++)
+    {
+        for (int j = 0; j < c; j++)
+        {
+            cin >> grid[i][j];
+        }
+    }
+    cout << maximumChocolates(r, c, grid);
+}
+
+// Sample Inputs
+
+// 3 4
+// 2 3 1 2
+// 3 4 2 2
+// 5 6 3 5
+
+// 2 2
+// 1 1
+// 1 2
+
+// Corresponding Outputs
+
+// 21
+
+// 5

From 5366cb1188a69bfe7ff1edfc6459b145a0d300fd Mon Sep 17 00:00:00 2001
From: Abhijeet Tiwari <abhijeet1862@gmail.com>
Date: Thu, 6 Oct 2022 02:10:42 +0530
Subject: [PATCH 197/203] changes made

---
 .../ninjaAndHisFriends.cpp                    | 40 ++++++++-----------
 1 file changed, 16 insertions(+), 24 deletions(-)

diff --git a/24- Dynamic Programming/ninjaAndHisFriends.cpp b/24- Dynamic Programming/ninjaAndHisFriends.cpp
index 53d990f..c366e82 100644
--- a/24- Dynamic Programming/ninjaAndHisFriends.cpp	
+++ b/24- Dynamic Programming/ninjaAndHisFriends.cpp	
@@ -1,14 +1,22 @@
-// Problem(3-D DP) : We are given an ‘N *M’ matrix.Every cell of the matrix has some chocolates on it, mat[i][j] gives us the
-// number of chocolates.We have two friends ‘Alice’ and ‘Bob’.initially, Alice is standing on the cell(0, 0) and Bob is standing
-// on the cell(0, M - 1).Both of them can move only to the cells below them in these three directions : to the bottom cell(↓),
-// to the bottom - right cell(↘), or to the bottom - left cell(↙). When Alica and Bob visit a cell, they take all the chocolates
-// from that cell with them. It can happen that they visit the same cell, in that case, the chocolates need to be considered only
-// once. They cannot go out of the boundary of the given matrix, we need to return the maximum number of chocolates that Bob and
-// Alice can together collect.
+// Problem(3-D DP) : https://www.codingninjas.com/codestudio/problems/ninja-and-his-friends_3125885
+
+// Sample Inputs
+// 3 4
+// 2 3 1 2
+// 3 4 2 2
+// 5 6 3 5
+// 2 2
+// 1 1
+// 1 2
+
+// Corresponding Outputs
+// 21
+// 5
 
 #include <bits/stdc++.h>
 using namespace std;
 
+// recursive function
 int f(int i, int j1, int j2, vector<vector<int>> &grid, int n, int m, vector<vector<vector<int>>> &dp)
 {
     if (i == n)
@@ -76,6 +84,7 @@ int f(int i, int j1, int j2, vector<vector<int>> &grid, int n, int m, vector<vec
     }
 }
 
+// function returning answer
 int maximumChocolates(int r, int c, vector<vector<int>> &grid)
 {
     vector<vector<vector<int>>> dp(r, vector<vector<int>>(c, vector<int>(c)));
@@ -106,20 +115,3 @@ int main()
     }
     cout << maximumChocolates(r, c, grid);
 }
-
-// Sample Inputs
-
-// 3 4
-// 2 3 1 2
-// 3 4 2 2
-// 5 6 3 5
-
-// 2 2
-// 1 1
-// 1 2
-
-// Corresponding Outputs
-
-// 21
-
-// 5

From a4673b0a46e3c5a852004b968ea9350b3526ea47 Mon Sep 17 00:00:00 2001
From: Abhijeet Tiwari <abhijeet1862@gmail.com>
Date: Thu, 6 Oct 2022 02:19:14 +0530
Subject: [PATCH 198/203] changes made

---
 .../minFallingPathSumTriangle.cpp             | 35 ++++++++-----------
 1 file changed, 14 insertions(+), 21 deletions(-)

diff --git a/24- Dynamic Programming/minFallingPathSumTriangle.cpp b/24- Dynamic Programming/minFallingPathSumTriangle.cpp
index d3b1fb9..c109bd4 100644
--- a/24- Dynamic Programming/minFallingPathSumTriangle.cpp	
+++ b/24- Dynamic Programming/minFallingPathSumTriangle.cpp	
@@ -2,9 +2,23 @@
 // adjacent number of the row below.More formally, if you are on index i on the current row, you may move to either
 // index i or index i + 1 on the next row.
 
+// Sample Inputs
+// 4
+// 2
+// 3 4
+// 6 5 7
+// 4 1 8 3
+// 1
+// -10
+
+// Corresponding Outputs
+// 11
+// -10
+
 #include <bits/stdc++.h>
 using namespace std;
 
+// recursive function
 int minimumTotal(vector<vector<int>> &triangle)
 {
     int n = triangle.size();
@@ -54,24 +68,3 @@ int main()
     }
     cout << minimumTotal(triangle);
 }
-
-// Sample Inputs
-
-// Sample Inputs
-
-// Sample Inputs
-
-// 4
-// 2
-// 3 4
-// 6 5 7
-// 4 1 8 3
-
-// 1
-// -10
-
-// Corresponding Outputs
-
-// 11
-
-// -10
\ No newline at end of file

From 984c1addc8dfea4712ae60a5e199d4fc471c40fa Mon Sep 17 00:00:00 2001
From: Dev Prakash Sharma <idevprakaash@gmail.com>
Date: Thu, 6 Oct 2022 19:49:39 +0530
Subject: [PATCH 199/203] Update ninjaAndHisFriends.cpp

---
 .../ninjaAndHisFriends.cpp                    | 27 ++++++++++---------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/24- Dynamic Programming/ninjaAndHisFriends.cpp b/24- Dynamic Programming/ninjaAndHisFriends.cpp
index c366e82..da31734 100644
--- a/24- Dynamic Programming/ninjaAndHisFriends.cpp	
+++ b/24- Dynamic Programming/ninjaAndHisFriends.cpp	
@@ -1,17 +1,20 @@
-// Problem(3-D DP) : https://www.codingninjas.com/codestudio/problems/ninja-and-his-friends_3125885
+// Problem(3-D DP) :
 
-// Sample Inputs
-// 3 4
-// 2 3 1 2
-// 3 4 2 2
-// 5 6 3 5
-// 2 2
-// 1 1
-// 1 2
+// We are given an ‘N *M’ matrix.Every cell of the matrix has some chocolates on it, mat[i][j] gives us the number of chocolates.We have two friends ‘Alice’ and ‘Bob’.initially, Alice is standing on the cell(0, 0) and Bob is standing on the cell(0, M - 1).Both of them can move only to the cells below them in these three directions: to the bottom cell(↓), to the bottom-right cell(↘), or to the bottom-left cell(↙). // When Alica and Bob visit a cell, they take all the chocolates from that cell with them. It can happen that they visit the same cell, in that case, the chocolates need to be considered only once. They cannot go out of the boundary of the given matrix, we need to return the maximum number of chocolates that Bob and Alice can together collect.
 
-// Corresponding Outputs
-// 21
-// 5
+/* Sample Inputs
+   3 4
+   2 3 1 2
+   3 4 2 2
+   5 6 3 5
+   2 2
+   1 1
+   1 2
+
+Corresponding Outputs
+   21
+   5
+ */
 
 #include <bits/stdc++.h>
 using namespace std;

From c64ca47c7cdaa2f7080a78d4697056ba15d77999 Mon Sep 17 00:00:00 2001
From: rahulranjan74 <106507426+rahulranjan74@users.noreply.github.com>
Date: Sun, 9 Oct 2022 18:32:07 +0530
Subject: [PATCH 200/203] PERMUTATION CREATE

Added  cpp file
---
 .../CodeChef Challenges/PERMCREATE.cpp        | 34 +++++++++++++++++++
 1 file changed, 34 insertions(+)
 create mode 100644 ONLINE JUDGE/CodeChef Challenges/PERMCREATE.cpp

diff --git a/ONLINE JUDGE/CodeChef Challenges/PERMCREATE.cpp b/ONLINE JUDGE/CodeChef Challenges/PERMCREATE.cpp
new file mode 100644
index 0000000..8e9f24d
--- /dev/null
+++ b/ONLINE JUDGE/CodeChef Challenges/PERMCREATE.cpp	
@@ -0,0 +1,34 @@
+#include <iostream>
+using namespace std;
+
+int main() {
+	// your code goes here
+	
+	long long number;
+	cin >> number;
+    for(int i = 0; i < number; i++){
+        long long  a;
+        cin >> a;
+        if(a < 4){
+            cout << -1 << endl;
+        }
+        else if( a == 4){
+            cout << 2 << " " << 4 << " " << 1  << " " << 3 ;
+        }
+        else{
+        for(long long i = 1; i <= a; i = i+2){
+            cout << i << " " ;
+        }
+        for(long long i = 2; i <= a; i = i+2){
+            cout << i << " ";
+        }
+        }
+      cout << endl;  
+    }
+	
+	
+	
+	
+	
+	return 0;
+}

From d7419e7f8dbc48d773b6f21f74233944d0a9197f Mon Sep 17 00:00:00 2001
From: Ishan Ahmad <nahidboss96@gmail.com>
Date: Mon, 9 Oct 2023 17:21:32 +0600
Subject: [PATCH 201/203] added code with right naming convension

---
 .../Alternate_Additions.cpp                   | 53 ++++++++++++++
 .../Chairs_Requirement.cpp                    | 39 +++++++++++
 .../CodeChef Challenges/Equal_Strings.cpp     | 64 +++++++++++++++++
 ONLINE JUDGE/CodeChef Challenges/MINSM.cpp    | 62 +++++++++++++++++
 ONLINE JUDGE/CodeChef Challenges/SEGM01.cpp   | 69 +++++++++++++++++++
 .../CodeChef Challenges/Subscriptions.cpp     | 40 +++++++++++
 6 files changed, 327 insertions(+)
 create mode 100644 ONLINE JUDGE/CodeChef Challenges/Alternate_Additions.cpp
 create mode 100644 ONLINE JUDGE/CodeChef Challenges/Chairs_Requirement.cpp
 create mode 100644 ONLINE JUDGE/CodeChef Challenges/Equal_Strings.cpp
 create mode 100644 ONLINE JUDGE/CodeChef Challenges/MINSM.cpp
 create mode 100644 ONLINE JUDGE/CodeChef Challenges/SEGM01.cpp
 create mode 100644 ONLINE JUDGE/CodeChef Challenges/Subscriptions.cpp

diff --git a/ONLINE JUDGE/CodeChef Challenges/Alternate_Additions.cpp b/ONLINE JUDGE/CodeChef Challenges/Alternate_Additions.cpp
new file mode 100644
index 0000000..ef67f08
--- /dev/null
+++ b/ONLINE JUDGE/CodeChef Challenges/Alternate_Additions.cpp	
@@ -0,0 +1,53 @@
+#include <bits/stdc++.h>
+using namespace std;
+
+#define ll long long
+#define pb(x) push_back(x)
+
+void setup();
+void solve();
+
+int main()
+{
+	setup();
+	solve();
+	return 0;
+}
+
+void solve()
+{
+	ll t;
+	cin >> t;
+	while(t--)
+	{
+		ll a, b;
+		cin >> a >> b;
+
+		if(b-a == 1 || b-a == 3) cout << "YES" << endl;
+		else if(b-a == 2) cout << "NO" << endl;
+		else
+		{
+			if((b-a)%3 == 0 || (b-a)%3 == 1) cout << "YES" << endl;
+			else cout << "NO" << endl;
+			// if(a%2 == 0 && b%2 == 0)
+			// else if(a%2 != 0 && b%2 != 0)
+			// else if(a%2 == 0 && b%2 != 0)
+			// else if(a%2 != 0 && b%2 == 0)
+		}
+	}
+}
+void setup()
+{
+	ios::sync_with_stdio(false);
+    cin.tie(NULL);
+    cout.tie(NULL);
+	#ifndef ONLINE_JUDGE
+    freopen("input.txt", "r", stdin);
+    freopen("output.txt", "w", stdout);
+	#else
+	#endif
+}
+
+// 2 -> 3, 5, 6, 8, 9, 11, 12
+// 3 -> 4, (6, 7,) (9, 10,) (12, 13)
+// 4 -> 5, 7, 8, 10, 11, 13, 14
\ No newline at end of file
diff --git a/ONLINE JUDGE/CodeChef Challenges/Chairs_Requirement.cpp b/ONLINE JUDGE/CodeChef Challenges/Chairs_Requirement.cpp
new file mode 100644
index 0000000..052d18a
--- /dev/null
+++ b/ONLINE JUDGE/CodeChef Challenges/Chairs_Requirement.cpp	
@@ -0,0 +1,39 @@
+#include <bits/stdc++.h>
+using namespace std;
+
+#define ll long long
+#define pb(x) push_back(x)
+
+void setup();
+void solve();
+
+int main()
+{
+	setup();
+	solve();
+	return 0;
+}
+
+void solve()
+{
+	ll t, x, y;
+	cin >> t;
+
+	while(t--)
+	{
+		cin >> x >> y;
+		if(x > y) cout << (x-y) << endl;
+		else cout << 0 << endl;
+	} 
+}
+void setup()
+{
+	ios::sync_with_stdio(false);
+    cin.tie(NULL);
+    cout.tie(NULL);
+	#ifndef ONLINE_JUDGE
+    freopen("input.txt", "r", stdin);
+    freopen("output.txt", "w", stdout);
+	#else
+	#endif
+}
\ No newline at end of file
diff --git a/ONLINE JUDGE/CodeChef Challenges/Equal_Strings.cpp b/ONLINE JUDGE/CodeChef Challenges/Equal_Strings.cpp
new file mode 100644
index 0000000..c8888c2
--- /dev/null
+++ b/ONLINE JUDGE/CodeChef Challenges/Equal_Strings.cpp	
@@ -0,0 +1,64 @@
+#include <bits/stdc++.h>
+#include <math.h>
+using namespace std;
+
+#define ll long long
+#define pb(x) push_back(x)
+
+void setup();
+void solve();
+
+int main()
+{
+	setup();
+	solve();
+	return 0;
+}
+
+void solve()
+{
+	ll t;
+	cin >> t;
+	while(t--)
+	{
+		ll n;
+		string s1, s2;
+
+		cin >> n >> s1 >> s2;
+
+		ll ss1 = s1.size(), ss2 = s2.size();
+
+		set <char> s;
+		ll c = 0;
+		for(ll i = 0; i < ss1; i++)
+		{
+			if(s1[i] != s2[i])
+			{
+				c++;
+				s.insert(s2[i]);
+			}
+		}
+
+		// cout << c << " " << s.size() << endl;
+		// for (auto itr : s)
+		//   {
+		//     cout << itr << " ";
+		//   }
+		//   cout << endl;
+		if(c > s.size()) cout << s.size() << endl;
+		else cout << c << endl;
+
+	}
+}
+void setup()
+{
+	ios::sync_with_stdio(false);
+    cin.tie(NULL);
+    cout.tie(NULL);
+	#ifndef ONLINE_JUDGE
+    freopen("input.txt", "r", stdin);
+    freopen("output.txt", "w", stdout);
+	#else
+	#endif
+}
+
diff --git a/ONLINE JUDGE/CodeChef Challenges/MINSM.cpp b/ONLINE JUDGE/CodeChef Challenges/MINSM.cpp
new file mode 100644
index 0000000..0715b54
--- /dev/null
+++ b/ONLINE JUDGE/CodeChef Challenges/MINSM.cpp	
@@ -0,0 +1,62 @@
+
+#include <bits/stdc++.h>
+using namespace std;
+
+#define ll        long long
+#define frp(a, b) for(ll i = a; i < b; i++)
+#define frn(a, b) for(ll i = a; i > b; i--)
+
+#define in(x)     insert(x)
+#define pb(x)     push_back(x)
+#define full(x)   x.begin(),x.end()
+
+ll gcd(ll a, ll b);
+void setup();
+void solve();
+
+int main()
+{
+	setup();
+	solve();
+	return 0;
+}
+
+void solve()
+{
+	ll T, N;
+	cin >> T;
+	while(T--)
+	{
+	    cin >> N;
+	    
+	     vector <ll> v(N);
+	     
+	     frp(0, N) cin >> v[i];
+	     
+	     sort(v.begin(), v.end());
+
+	     ll g = v[0];
+
+	     for(ll j = 1; j < N; j++) g = gcd(g, v[j]);
+
+	     cout << g*N << endl;
+
+	}
+}
+
+ll gcd(ll a, ll b)
+{
+	if(a%b == 0) return b;
+	else return gcd(b, a%b);
+}
+void setup()
+{
+	ios::sync_with_stdio(false);
+    cin.tie(NULL);
+    cout.tie(NULL);
+	#ifndef ONLINE_JUDGE
+    freopen("input.txt", "r", stdin);
+    freopen("one.txt", "w", stdout);
+	#else
+	#endif
+}
\ No newline at end of file
diff --git a/ONLINE JUDGE/CodeChef Challenges/SEGM01.cpp b/ONLINE JUDGE/CodeChef Challenges/SEGM01.cpp
new file mode 100644
index 0000000..eff84d0
--- /dev/null
+++ b/ONLINE JUDGE/CodeChef Challenges/SEGM01.cpp	
@@ -0,0 +1,69 @@
+#include <iostream>
+#include <cmath>
+#include <algorithm>
+
+using namespace std;
+
+void solve();
+
+int main()
+{
+
+    solve();
+
+    return 0;
+}
+
+void solve()
+{
+	int t;
+	string s;
+
+	cin >> t;
+
+	while(t--)
+	{
+		cin >> s;
+
+		int ss = s.size(), f = 0, c = 0;
+
+		for(int i = 0; i < ss; i++)
+		{
+			if(s[i] == 49)
+			{
+				c++;
+				f = i;
+			}
+		}
+
+		if(c == 0)
+		{
+			cout << "NO" << endl;
+		}
+		else
+		{
+			for(int i = f; i >= 0; i--)
+			{
+				if(s[i] == 48)
+				{
+					break;
+				}
+				else
+				{
+					c--;
+				}
+			}
+
+			//cout << c << endl;
+			if(c == 0)
+			{
+				cout << "YES" << endl;
+			}
+			else
+			{
+				cout << "NO" << endl;
+			}
+		}
+		
+	}
+}
\ No newline at end of file
diff --git a/ONLINE JUDGE/CodeChef Challenges/Subscriptions.cpp b/ONLINE JUDGE/CodeChef Challenges/Subscriptions.cpp
new file mode 100644
index 0000000..3d89425
--- /dev/null
+++ b/ONLINE JUDGE/CodeChef Challenges/Subscriptions.cpp	
@@ -0,0 +1,40 @@
+#include <bits/stdc++.h>
+using namespace std;
+
+#define ll long long
+#define pb(x) push_back(x)
+
+void setup();
+void solve();
+
+int main()
+{
+	setup();
+	solve();
+	return 0;
+}
+
+void solve()
+{
+	ll t;
+	cin >> t;
+	while(t--)
+	{
+		ll n, x;
+		cin >> n >> x;
+
+		if(n <= 6) cout << x << endl;
+		else cout << int(ceil(n/6.0)*x) << endl;
+	}
+}
+void setup()
+{
+	ios::sync_with_stdio(false);
+    cin.tie(NULL);
+    cout.tie(NULL);
+	#ifndef ONLINE_JUDGE
+    freopen("input.txt", "r", stdin);
+    freopen("output.txt", "w", stdout);
+	#else
+	#endif
+}
\ No newline at end of file

From d8da13958117a80739538d403908d266448e33ed Mon Sep 17 00:00:00 2001
From: Rishabh Kanth <72266058+RishabhK200@users.noreply.github.com>
Date: Thu, 19 Oct 2023 21:04:33 +0530
Subject: [PATCH 202/203] Singly Linked List Implementation

Implementation of singly linked list with all the methods required in a single program
---
 13- Linked Lists/SingleLL1.cpp | 159 +++++++++++++++++++++++++++++++++
 1 file changed, 159 insertions(+)
 create mode 100644 13- Linked Lists/SingleLL1.cpp

diff --git a/13- Linked Lists/SingleLL1.cpp b/13- Linked Lists/SingleLL1.cpp
new file mode 100644
index 0000000..843a32b
--- /dev/null
+++ b/13- Linked Lists/SingleLL1.cpp	
@@ -0,0 +1,159 @@
+#include <bits/stdc++.h>
+using namespace std;
+
+class node{
+
+    public: 
+        int value ;
+        node* next ;
+
+        node(int data){
+            value = data;
+            next = NULL;
+        }
+};
+
+// inserting at the head
+void insertAtHead( node* &head, int val){          // take by reference as we have to change the value of head
+    node* new_node = new node(val);                
+    new_node-> next = head ;
+    head = new_node;
+}
+
+// inserting at the tail
+void insertAtTail(node* &head, int val){
+
+    node* new_node =  new node(val) ;
+    node* temp = head;
+    
+    while(temp->next!=NULL){
+        temp = temp->next;
+        
+    }
+    // temp has reached last node
+    temp->next = new_node;                             // already points to NULL by the constuctor
+
+}
+
+// to insert the kth node 
+void insertAtPosition(node* head, int val, int pos){
+
+    if(pos ==0 ) {
+        insertAtHead( head, val) ;
+        return ;
+    }
+
+    node* new_node = new node(val) ;
+    node* temp = head;
+    int cur_pos = 0;
+
+    while(cur_pos!=pos-1){
+        temp = temp->next;
+        cur_pos++;
+    }
+
+    // temp is pointing to pos-1
+
+    new_node->next = temp->next;
+    temp->next = new_node;
+    
+}
+ 
+// to update at kth node
+void updateAtPosition(node* head, int val, int pos){
+
+    node* temp = head;
+    int curr_pos = 0;
+    
+    while(curr_pos!=pos){
+
+        temp = temp->next;
+        curr_pos++; }
+
+    temp->value = val;
+}
+
+// to delete at head
+void deleteAtHead(node* &head){
+
+    node* temp = head;
+
+    head = temp->next;
+    delete temp;
+}
+
+// to delete at the last
+void deleteAtTail(node* head){
+
+    node* second_last = head;
+    while(second_last->next->next != NULL){
+        second_last= second_last->next;
+    }
+
+    node* temp = second_last->next;
+    second_last->next = NULL;
+
+    delete temp;
+
+}
+
+// to print all the nodes
+void display(node* head){
+    node* temp= head;
+
+    while(temp!=NULL){
+        cout << temp->value << "->" ;
+        temp = temp->next; 
+    }
+    cout << "NULL" << endl;
+}
+
+// to delete at kth position
+void deleteAtPosition(node* &head, int pos){
+
+    if(pos==0){
+        deleteAtHead(head);
+        return;
+    }
+
+    node* prev = head;
+    int curr_pos = 0;
+
+    while(curr_pos!=pos-1){
+        prev= prev->next;
+        curr_pos++;
+    }
+    node* temp = prev->next;
+    prev->next = prev->next->next;
+    delete temp;
+
+}
+
+int main(){
+
+    // node *n = new node(1);
+
+    // cout << n->value << " " << n->next;
+
+    node* head = NULL ;                 // empty linked list
+
+    insertAtHead(head,2);
+    insertAtHead(head,1);
+    insertAtTail(head,4);
+    insertAtPosition(head,5,1);
+
+    display(head);
+
+    updateAtPosition(head,7,1);
+
+    display(head);
+
+    // deleteAtHead(head);
+    // deleteAtTail(head);
+     deleteAtPosition(head,2) ;
+
+    display(head);
+
+
+    return 0;
+}
\ No newline at end of file

From e188b0808d91308a2b993c14b5fa453cf0fe60cd Mon Sep 17 00:00:00 2001
From: Rishabh Kanth <72266058+RishabhK200@users.noreply.github.com>
Date: Thu, 19 Oct 2023 22:06:24 +0530
Subject: [PATCH 203/203] Singly Linked List Problems

All the Important problems of singly linked list accumulated in a a single program
---
 13- Linked Lists/SingleLL1ques.cpp | 604 +++++++++++++++++++++++++++++
 1 file changed, 604 insertions(+)
 create mode 100644 13- Linked Lists/SingleLL1ques.cpp

diff --git a/13- Linked Lists/SingleLL1ques.cpp b/13- Linked Lists/SingleLL1ques.cpp
new file mode 100644
index 0000000..ed551b9
--- /dev/null
+++ b/13- Linked Lists/SingleLL1ques.cpp	
@@ -0,0 +1,604 @@
+#include <bits/stdc++.h>
+using namespace std;
+
+class Node{
+
+    public:
+    int data;
+    Node* next;
+
+    Node(int val){
+        data = val;
+        next = NULL;
+    }
+};
+
+class Linkedlist{
+    public:
+        Node* head;                               // head is common so don't need to put in every function
+
+        Linkedlist(){                              // when we initailize the linkedlist
+            head = NULL;   
+        }
+
+        void insertAtTail(int val){
+
+            Node* new_node = new Node(val);
+
+            if(head==NULL) {                        // if linkedlist is empty;
+                head = new_node;
+                return;
+            }
+
+             Node* temp = head;
+
+            while(temp->next!=NULL){
+                temp = temp->next;
+            }
+            temp->next = new_node;
+        }
+
+        void display(){
+            
+            Node* temp = head;
+            while(temp!=NULL){
+                cout << temp->data << "->";
+                temp = temp->next;
+            }
+            cout << "NULL" <<endl;
+        }
+};
+
+
+    void alternateDelete(Node* &head) {
+
+        Node* curr = head;
+
+        while(curr!=NULL && curr->next!=NULL){
+            Node* temp = curr->next;
+            curr->next = curr->next->next;
+            delete temp;
+            curr = curr->next;
+        }
+    }
+
+    void sorteddelDuplicates(Node* &head){
+
+        Node* curr = head;
+
+        while(curr!=NULL){
+
+            while(curr->next && curr->data == curr->next->data) {
+                Node* temp = curr->next;                                         // node to be deleted
+                curr->next = curr->next->next;
+                delete temp;
+            }
+            curr = curr->next;
+        }
+    }
+
+    void displayrev(Node* head){
+
+        if(head == NULL) {
+            cout << "NULL->" ;
+            return ;
+        }
+
+        displayrev(head->next);
+        cout << head->data << "->" ;
+    }
+
+    Node* revLinkedList(Node* &head){
+
+        Node* prev = NULL;
+        Node* curr = head;                     // put curr->next = prev and move all 3 pointers by 1 step
+
+        while(curr!=NULL){
+            Node* next = curr->next;
+            curr->next = prev;
+            prev = curr;
+            curr = next;
+        }
+        
+        // head= prev;
+        Node* new_head = prev;
+        return new_head;
+    }
+
+    Node* revRecurinkedList(Node* head) {
+
+        // base case
+        if(head == NULL || head->next==NULL) return head ;   // only one node left
+
+        Node* new_head = revRecurinkedList(head->next);
+
+        head->next->next = head;
+        head->next=NULL;
+
+        return new_head;
+
+    }
+
+    Node* reverseKLL(Node* head, int k){
+
+        // first reverse iteratively the k elements
+        Node* prev = NULL;
+        Node* curr = head;
+        int cnt = 0;
+
+        while(curr!=NULL && cnt<k){
+
+            Node* next = curr->next;
+            curr->next = prev;
+
+            prev = curr;
+            curr = next;
+            cnt++;
+        }
+
+        if(curr!=NULL){
+            Node* new_head = reverseKLL(curr, k) ;        // curr will be its head
+            head->next = new_head ;
+        }
+
+        return prev;
+    }
+
+    // check if two linked list are equal or not
+      bool checkEqualLL(Node* head1, Node* head2){
+
+        Node* ptr1 = head1;
+        Node* ptr2 = head2;
+
+        while(ptr1!=NULL && ptr2!=NULL) {
+
+            if(ptr1->data!=ptr2->data) return false;
+
+            ptr1=ptr1->next;
+            ptr2=ptr2->next;
+
+        }
+          return (ptr1==NULL && ptr2 == NULL) ;
+
+    }
+
+    // to get length 
+    int getlength(Node* head){
+
+        Node* temp = head;
+        int len = 0;
+
+         while(temp!=NULL) {
+            len++;
+            temp = temp->next;
+        }
+
+        return len;
+    }
+
+    // check the intersection points of two linked list
+    Node* getIntersection(Node* head1, Node* head2){
+
+        // to calculate length of each node
+        Node* ptr1 = head1;
+        Node* ptr2 = head2;
+
+        int l1=getlength(ptr1), l2=getlength(ptr2);
+
+        int diff = abs(l1-l2);
+
+        if(l1>l2) { while(diff) {
+            ptr1 = ptr1->next;
+            diff--; }
+        }
+
+        if(l2>l1) { while(diff) {
+            ptr2 = ptr2->next;
+            diff--; }
+        }
+
+        while(ptr1!=NULL) {
+
+            if(ptr1->data == ptr2->data) return ptr1;
+            ptr1=ptr1->next;
+            ptr2=ptr2->next;
+        }
+
+        return NULL;
+        
+    }
+
+    //delete from last
+    void deletefromLast(Node* &head, int k){
+
+        // Node* temp = head;
+
+        // int len = getlength(head);
+        // int ptr = len-k;
+
+        // if(ptr==0) return (head=head->next);
+
+        // while(ptr>1) {
+        //     temp= temp->next;
+        //     ptr--;
+        // }
+
+        // temp->next = temp->next->next;
+
+        // return head;
+
+        Node* ptr1 = head;
+        Node* ptr2 = head;
+
+        int cnt = k;
+
+        while(cnt--){
+            ptr2 = ptr2->next;
+        }
+
+        // k is eual to the length of the linked list
+        if(ptr2==NULL) {
+            Node* temp = head;
+            head= head->next;
+            delete temp;
+        } 
+
+
+        while(ptr2->next!=NULL){
+
+            ptr1 = ptr1->next;
+            ptr2 = ptr2->next;
+        }
+
+        Node* temp = ptr1->next; 
+        ptr1->next = ptr1->next->next;
+        delete temp;
+
+    }
+
+    // to merge two linked list
+    Node* mergeLL(Node* &head1, Node* &head2){
+
+        Node* dummy_head = new Node(-1);
+
+        Node* ptr1 = head1;
+        Node* ptr2 = head2;
+        Node* ptr3 = dummy_head;
+
+        while(ptr1!=NULL && ptr2!=NULL) {
+
+            if(ptr1->data<ptr2->data) {
+                ptr3->next = ptr1;
+                ptr1 = ptr1->next;
+                ptr3 = ptr3->next;
+            }
+
+            else {
+
+                ptr3->next = ptr2;
+                ptr2 = ptr2->next;
+                ptr3 = ptr3->next;
+            } 
+        }
+ 
+        if(ptr1) ptr3->next = ptr1;
+        else if(ptr2) ptr3->next = ptr2;
+
+        return dummy_head->next;
+
+    }
+    
+    // to merge k linked list
+    Node* mergedKLL(vector<Node*> & list) {                              // list of head nodes
+
+        if(list.size() == 0) return NULL;                                // when list is empty
+
+        while(list.size()>1){                                            // loop till only one left in the node
+
+            Node* new_head = mergeLL(list[0],list[1]);      
+            list.push_back(new_head);
+            list.erase(list.begin());
+            list.erase(list.begin());
+        }
+
+        return list[0];                                                // return the last remaining node 
+    }
+
+    // to find middle of a linked list
+    int middleOfLinkedList(Node* head){
+
+        Node* ptr1 = head;
+        Node* ptr2 = head;
+
+        while(ptr2!=NULL && ptr2->next!=NULL){
+
+            ptr2 = ptr2->next->next;                   // fast pointer
+            ptr1 = ptr1->next ;                        // slow pointer
+        }
+
+        return ptr1->data;
+    }
+
+    // to detect cycle in a Linkedlist
+    bool detectCycle(Node* head){
+
+        if(head==NULL) return false;
+
+        Node* slow = head;
+        Node* fast = head;
+
+        while(fast!=NULL && fast->next!=NULL){
+            
+            slow = slow->next;
+            fast = fast->next->next;
+
+            if(slow == fast) {
+                cout << slow->data <<endl;
+                return true;
+            }
+        }
+
+        return false ;
+    }
+
+    // to remove the cycle
+    void removeCycle(Node* head){
+
+        Node* slow = head;
+        Node* fast = head;
+
+         do{                                                       // do while as at first they are pointing to the same
+            slow = slow->next;
+            fast = fast->next->next;
+        }  while(slow!=fast) ;
+
+        fast = head;
+
+        while(fast->next!=slow->next){
+            slow = slow->next;
+            fast = fast->next;
+        }
+
+        slow->next = NULL; 
+
+    }
+
+    // to check palindrome or not
+    bool isPalindrome(Node* head){
+
+        // 1) to find middle element
+        Node* slow =head;
+        Node* fast = head;
+
+        while(fast!=NULL && fast->next!=NULL){
+            slow = slow->next;
+            fast=fast->next->next;
+        }
+
+    // slow is pointing to the middle
+    // 2) break the linked list in the middle
+
+        Node* curr = slow->next;
+        Node* prev = slow;
+        slow->next = NULL;
+
+        // 3) reverse second half of linked list
+
+        while(curr!=NULL) {
+            Node* next = curr->next;
+            curr->next = prev;
+            prev = curr;
+            curr = next;
+        }
+        
+        // prev is pointing to new head
+        // 4) Comapare the two linked list
+
+        Node* head1 = head;
+        Node* head2 = prev;
+
+        while(head2!=NULL ){
+
+            if(head2->data!=head1->data) return false;
+
+            head2 = head2->next;
+            head1 = head1->next;
+        }
+
+        return true;
+        
+    }
+
+    // to rotate the linkedlist by k elements
+    Node* rotateByK(Node* &head, int k) {
+        
+        // 1) calculating length of linkedlist
+        int n = 0;
+
+        //2) find tail node
+        Node* tail = head;
+
+        while(tail->next!=NULL) {
+            n++;
+            tail = tail->next;
+        }
+        n++;
+        k = k%n;                                 // if k is greater than n
+        if (k==0) return head;
+
+        tail->next = head;   
+
+        //3) traverse n-k nodes
+        Node* temp = head;
+
+        for(int i=0;i<n-k;i++){
+            temp = temp->next;
+        }
+
+        // temp now pointing to (n-k)th node
+
+        Node* new_head = temp->next;
+        temp->next = NULL;
+
+        return new_head;
+
+    }
+    
+    // to segregate even and odd linked list
+    Node* oddEvenLinkedList(Node* head){
+
+        if(head==NULL) return head;
+
+        Node* even_head = head->next;
+        Node* oddPtr = head;
+        Node* evenPtr = even_head;
+
+
+        while(evenPtr!=NULL && evenPtr->next!=NULL){
+
+            oddPtr->next = oddPtr->next->next;
+            evenPtr->next = evenPtr->next->next;
+            
+            oddPtr = oddPtr->next;
+            evenPtr = evenPtr->next;
+        }
+
+        oddPtr->next = even_head;
+
+        return head;
+    }
+
+    // to reorder the linked list and print accordingly
+    Node* reorderLinkedList(Node* &head){
+
+        //1) finding middle element
+
+        Node* slow = head;
+        Node* fast = head;
+
+        while(fast && fast->next){
+            slow = slow->next;
+            fast = fast->next->next;
+        }
+
+        // now slow is pointing to the middle
+        // 2) now separate the linked list and reverse the second half
+
+        Node* prev = slow;
+        Node* curr = slow->next;
+        slow->next = NULL;
+
+        while(curr){
+            Node* next = curr->next;
+            curr->next = prev;
+            prev = curr;
+            curr = next;
+
+        }
+
+        // 3) merging the two halves of the linked list
+
+        Node* ptr1 = head;    // linked list 1
+        Node* ptr2 = prev;    // linked list 2
+
+        while(ptr1!=ptr2){
+            
+            Node* temp = ptr1->next;
+            ptr1->next = ptr2;
+            ptr1 = ptr2;
+            ptr2 = temp;
+        }
+
+        return head;
+    }
+
+
+int main(){
+
+    Linkedlist ll;
+    ll.insertAtTail(1);
+    ll.insertAtTail(2);
+    ll.insertAtTail(3);
+    ll.insertAtTail(4);
+    ll.insertAtTail(5);
+    ll.insertAtTail(6);
+    // ll.insertAtTail(1);
+    // ll.insertAtTail(8);
+    // ll.insertAtTail(3);
+
+    ll.display();
+
+    // alternateDelete(ll.head);
+    // sorteddelDuplicates(ll.head);
+
+    // displayrev(ll.head);
+
+    // ll.head = revLinkedList(ll.head);
+    // revLinkedList(ll.head);
+
+    // ll.head = revRecurinkedList(ll.head);
+
+    // ll.head = reverseKLL(ll.head,2);
+
+    // ll.display();
+
+    // Linkedlist ll2;
+    // ll2.insertAtTail(2);
+    // ll2.insertAtTail(3);
+    // ll2.insertAtTail(10);
+    // ll2.insertAtTail(11);
+    // ll2.insertAtTail(342);
+
+    // ll2.display();
+
+    // bool flag =  checkEqualLL(ll.head,ll2.head);
+    // if(flag==1) cout << "True" ;
+    // else cout << "False";
+
+//    Node* intersection =  getIntersection(ll.head, ll2.head) ;
+//     if(intersection) cout << intersection->data;
+//     else cout << -1;
+
+// int length = getlength(ll.head);
+// cout << length <<endl;
+
+// ll.head = deletefromLast(ll.head,1);
+
+// deletefromLast(ll.head,2);
+
+
+
+//    ll2.display();
+
+//    Linkedlist ll3;
+
+//    ll3.head = mergeLL(ll.head,ll2.head);
+
+//    ll3.display();
+
+
+// int mid = middleOfLinkedList(ll.head);
+
+// cout << mid <<endl;
+
+// int flag = detectCycle(ll.head);
+
+// if(flag==1) cout << "True" <<endl;
+// else cout << "False" <<endl;
+
+
+// ll.head->next->next->next->next->next->next->next->next = ll.head->next->next;
+
+// removeCycle(ll.head);
+
+// ll.display();
+
+// cout << isPalindrome(ll.head) << endl;
+
+// ll.head = rotateByK(ll.head, 3);
+
+ll.head = oddEvenLinkedList(ll.head);
+
+ll.display();
+
+}
\ No newline at end of file
