master 6bab395fbefe cached
212 files
192.6 KB
58.1k tokens
480 symbols
1 requests
Download .txt
Showing preview only (238K chars total). Download the full file or copy to clipboard to get everything.
Repository: Prince-1501/Hello_world-Competiitve-Programming
Branch: master
Commit: 6bab395fbefe
Files: 212
Total size: 192.6 KB

Directory structure:
gitextract_md51_btr/

├── 35_hacker_two_strings.cpp
├── 36_codechef_Encoding_message.cpp
├── 37_codechef_spell_bob.cpp
├── 38_codechef_fits_square_in_triangle.cpp
├── 39_codechef_chef_and_Eid.cpp
├── 40_codechef_chef_judges_competition.cpp
├── 41_codechef_chef_and_glove.cpp
├── 42_codechef_the_great_run.cpp
├── 43_codechef_attendance.cpp
├── 44_codechef_making_a_meal.cpp
├── 45_codechef_uncle_johny.cpp
├── 46_drink_codeforce.cpp
├── 47_candles_codeforces.cpp
├── 49_two_buttons_codeforces.cpp
├── 50_vanya_and_books_codeforces.cpp
├── 51_eleven_codeforces.cpp
├── 52_codechef_flatland.cpp
├── 53_codeforces_MUH_and_sticks.cpp
├── 54_print_subset_of_size_k_of_array.cpp
├── 55_codechef_Easy_Fibonacci.cpp
├── 56_codechef_Chef_and_Interesting_Subsequences.cpp
├── 57_codechef_A-books.cpp
├── 58_codechef_phone_prices.cpp
├── 59_codechef_operations_on_a_matrix.cpp
├── 60_Adding_one_to_the_numbers.cpp
├── Chef and Price Control.cpp
├── Data Structures/
│   ├── Add a node at the Middle of linked list.cpp
│   ├── Add a node at the end of linked list.cpp
│   ├── Add a node at the front of linked list.cpp
│   ├── Array_in_data_structures.cpp
│   ├── Circular Linked List data_structure.cpp
│   ├── Delete a node of a linked list.cpp
│   ├── Doubly Linked list.cpp
│   ├── Find the middle of a given linked list.cpp
│   ├── Insert Node at the End of Doubly Linked List.cpp
│   ├── Insert Node in Middle of Doubly Linkedlist.cpp
│   ├── LinkedList_Code_Practice.cpp
│   ├── Vectors_in_STL_data_structure.cpp
│   ├── main.cpp
│   └── structure_in_c++.cpp
├── Kadane's_algorithm.cpp
├── Kadane's_algorithm.pptx
├── Lecture - 15.cpp
├── Lecture - 16.cpp
├── Lecture - 17.cpp
├── Lecture - 18.cpp
├── Lecture - 19.cpp
├── Lecture - 20.cpp
├── Lecture - 21.cpp
├── Lecture - 22.cpp
├── Lecture - 24.cpp
├── Lecture - 25.cpp
├── Lecture - 26.cpp
├── Lecture - 27.cpp
├── Lecture - 31.cpp
├── Lecture - 32.cpp
├── Lecture - 33.cpp
├── Lecture - 34.cpp
├── Leetcode/
│   ├── Add Digits.cpp
│   ├── Add Two Numbers Leetcode Solutions in Linkedlist.cpp
│   ├── Binary Search leetcode Solution.cpp
│   ├── Boolean Matrix.cpp
│   ├── Count the Number of Consistent Strings.cpp
│   ├── Graph/
│   │   ├── All Paths From Source to Target.cpp
│   │   ├── Course Schedule.cpp
│   │   ├── Detect cycle in a directed graph.cpp
│   │   ├── Find Eventual Safe States.cpp
│   │   ├── Find if Path Exists in Graph.cpp
│   │   ├── Find the Town Judge.cpp
│   │   ├── Flood Fill.cpp
│   │   ├── Keys and Rooms.cpp
│   │   ├── Max Area of Island.cpp
│   │   ├── Minimum Time to Collect All Apples in a Tree.cpp
│   │   ├── Number of Enclaves.cpp
│   │   ├── Number of Islands.cpp
│   │   ├── Number of Provinces.cpp
│   │   ├── Number of closed Islands.cpp
│   │   ├── Rotting Oranges.cpp
│   │   ├── Steps by Knight.cpp
│   │   ├── Surrounded Regions.cpp
│   │   ├── Time Needed to Inform All Employees.cpp
│   │   ├── Topological sort .cpp
│   │   └── Topological sort using dfs.cpp
│   ├── Hashing/
│   │   ├── Check if two arrays are equal or not.cpp
│   │   ├── Custom Sort String.cpp
│   │   ├── First Repeating Element.cpp
│   │   ├── Group Anagrams.cpp
│   │   ├── Intersection of two arrays.cpp
│   │   ├── Key Pair.cpp
│   │   ├── LFU Cache.cpp
│   │   ├── Non-Repeating Element.cpp
│   │   ├── Pairs with Positive Negative values.cpp
│   │   ├── Relative Sort Array.cpp
│   │   ├── Sort Array by Increasing Frequency.cpp
│   │   ├── Subarray with 0 sum.cpp
│   │   ├── Winner of an election.cpp
│   │   ├── unordered_map.cpp
│   │   └── unordered_set.cpp
│   ├── Interchanging the rows of a Matrix.cpp
│   ├── Majority Element Geeksforgeeks leetcode Moore's Voting Algorithm.cpp
│   ├── Median of Two sorted arrays.cpp
│   ├── Middle of the Linked List Leetcode.cpp
│   ├── Middle of the Linked List.cpp
│   ├── Move Zeroes.cpp
│   ├── Multiply two matrices.cpp
│   ├── Naive Pattern Search.cpp
│   ├── Next Greater Element.cpp
│   ├── Non Repeating Character.cpp
│   ├── Peak element.cpp
│   ├── Rearrange Array Alternately Geeksforgeeks.cpp
│   ├── Recursion/
│   │   ├── 0-1 Knapsack Problem Top down.cpp
│   │   ├── Best Time to Buy and Sell Stock.cpp
│   │   ├── Climbing Stairs.cpp
│   │   ├── Decode Ways.cpp
│   │   ├── Delete middle element of a stack.cpp
│   │   ├── Divisor Game.cpp
│   │   ├── Factorial.cpp
│   │   ├── Fibonacci Number.cpp
│   │   ├── House Robber.cpp
│   │   ├── Largest Element in Array.cpp
│   │   ├── Min Cost Climbing Stairs.cpp
│   │   ├── Nth Fibonacci Number.cpp
│   │   ├── Partition Equal Subset Sum.cpp
│   │   ├── Perfect Squares.cpp
│   │   ├── Perfect Sum Problem.cpp
│   │   ├── Power Of Numbers.cpp
│   │   ├── Print 1 To N Without Loop.cpp
│   │   ├── Reverse a String.cpp
│   │   ├── Subset Sum Problem.cpp
│   │   ├── Sum of Array.cpp
│   │   ├── Target Sum.cpp
│   │   └── Tower Of Hanoi.cpp
│   ├── Reverse Linked List.cpp
│   ├── Rotate Array Leetcode.cpp
│   ├── Rotate List.cpp
│   ├── Search in a row-column sorted Matrix.cpp
│   ├── Single Number Leetcode solution.cpp
│   ├── Sort Array By Parity.cpp
│   ├── Sort Colors.cpp
│   ├── Spirally traversing a matrix.cpp
│   ├── Square root.cpp
│   ├── Subarray sum equals K.cpp
│   ├── Trapping Rain Water.cpp
│   ├── Tree/
│   │   ├── Balanced Binary Tree.cpp
│   │   ├── Binary Tree Inorder Traversal.cpp
│   │   ├── Binary Tree Right Side View.cpp
│   │   ├── Binary Tree Zigzag Level Order Traversal.cpp
│   │   ├── Children Sum Parent.cpp
│   │   ├── Construct Binary Tree from Preorder and Inorder Traversal.cpp
│   │   ├── Diameter of Binary Tree.cpp
│   │   ├── Invert Binary Tree.cpp
│   │   ├── Level Order Traversal.cpp
│   │   ├── Lowest Common Ancestor of a Binary Tree.cpp
│   │   ├── Maximum Depth of Binary Tree.cpp
│   │   ├── Populating Next Right Pointers in Each Node.cpp
│   │   ├── Subtree of Another Tree.cpp
│   │   ├── Symmetric Tree.cpp
│   │   ├── Vertical Width of a Binary Tree .cpp
│   │   └── same Tree.cpp
│   ├── count 1's in binary array.cpp
│   ├── linked-list-cycle.cpp
│   ├── linkedlist/
│   │   ├── Copy List with Random Pointer.cpp
│   │   ├── Delete Node in a Linked List.cpp
│   │   ├── Intersection of Two Linked Lists.cpp
│   │   ├── Linked List Cycle II.cpp
│   │   ├── Merge Two Sorted Lists.cpp
│   │   ├── Palindrome Linked List.cpp
│   │   ├── Remove Duplicates from Sorted List.cpp
│   │   ├── Remove Nth Node From End of List.cpp
│   │   ├── Remove duplicates from an unsorted linked list.cpp
│   │   ├── Reverse Linked List.cpp
│   │   ├── Sort List.cpp
│   │   ├── Swap Nodes in Pairs.cpp
│   │   └── Swapping Nodes in a Linked List.cpp
│   ├── stack/
│   │   ├── Evaluate Reverse Polish Notation.cpp
│   │   ├── Implement Queue using Stacks.cpp
│   │   ├── Implement Stack using Queues.cpp
│   │   ├── Largest Rectangle in Histogram.cpp
│   │   ├── Min Stack.cpp
│   │   ├── Next Greater Element I.cpp
│   │   ├── Online Stock Span.cpp
│   │   ├── Remove All Adjacent Duplicates In String.cpp
│   │   ├── Remove All Adjacent Duplicates in String II.cpp
│   │   ├── Reverse First K elements of Queue.cpp
│   │   └── Valid Parentheses.cpp
│   ├── string/
│   │   ├── Find the Index of the First Occurrence in a String.cpp
│   │   ├── Gas Station.cpp
│   │   └── Maximum Ice Cream Bars.cpp
│   └── sum of numbers in string.cpp
├── README.md
├── STL/
│   ├── Array_Algorithms_in_stl.cpp
│   ├── Binary search in STL.cpp
│   ├── List_in_STL.cpp
│   ├── Queue_in_STL.cpp
│   ├── Vectors_Functions_in_STL.cpp
│   ├── What is STL.cpp
│   ├── deque_in_STL.cpp
│   ├── pair_in_STL.cpp
│   ├── priority Queue in STL.cpp
│   ├── sort_in_STL.cpp
│   └── stack in STL data structure.cpp
├── Templates_in_c++.cpp
├── Tree/
│   ├── Binary seacrh tree
│   ├── Binary_tree.cpp
│   ├── Code of Deletion of Node in BST.cpp
│   ├── Code of Inorder Traversal.cpp
│   ├── Insertion in BST.cpp
│   ├── code of Hashing in C++.cpp
│   └── code of preorer and Postorder traversal.cpp
├── chef and Icecream.cpp
├── chef and string.cpp
└── map_in_c++

================================================
FILE CONTENTS
================================================

================================================
FILE: 35_hacker_two_strings.cpp
================================================
//
//  main.cpp
//  Lecture 34
//
//  Created by Prince  Kumar on 17/04/19.
//  Copyright © 2019 Prince  Kumar. All rights reserved.
//
//                      HACKER EARTH

//       --- **    Problems on Two Strings   ** ---           //


#include <iostream>
using namespace std;
int main()
{
    int T; cin>>T;
    while(T--)
    {
        string s1,s2; cin>>s1>>s2;
        // declare array for s1 and s2;
        
        // for s1
        int a[26]={0};
        
        // for s2
        int b[26]={0};
        
        // length of string
        int k = (int)s1.size();
        
        for(int i=0;i<k;i++)
        {
            int x = s1[i]-97;  //  In c++ automatic data type conversion in char to int
            a[x]++;
            
            int y = s2[i]-97;
            b[y]++;
        }
        
        
        // we declare count
        int count=0;
        
        // we got completer array a and b
        
        for(int j=0;j<26;j++)
        {
            if(a[j]!=b[j])
                count++;
        }
        if(count==0)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
}




================================================
FILE: 36_codechef_Encoding_message.cpp
================================================
//
//  main.cpp
//  Lecture 36
//
//  Created by Prince  Kumar on 17/04/19.
//  Copyright © 2019 Prince  Kumar. All rights reserved.
//
//                      CODE-CHEF

//       --- **    Problems on Encoding Message   ** ---       //


#include <iostream>
using namespace std;
int main()
{
    int T; cin>>T;
    while(T--)
    {
        int n; cin>>n; // lenght of string
        string s; cin>>s;
        
        // 1st step of encoding
        if(n%2==0)
        {
            // even
            for(int i=0;i<n;i=i+2)  // len= 6 ; index -> 0 to 5
            {
                char z = s[i+1];  // z='h'
                s[i+1] = s[i] ;  //
                s[i]=z;
            }
        }
        else
        {
            // odd
            for(int i=0;i<n-1;i=i+2)
            {
                char z = s[i+1];  // z='h'
                s[i+1] = s[i] ;  //
                s[i]=z;
            }
        }
        
        // 2nd stage of encoding
        
        for(int i=0;i<n;i++)
        {
            char c = s[i];   // recent character  // b --> 98
            //int index  =  s[i]-97;
            int index  =  c-97;   // 1
            int req = 25-index;   // 24
            
            //  range 97 to 122
            req = req + 97;
            char y = (char)req;  // real ASCII code
            cout<<y;
            
        }
        cout<<endl;
        
        
        
    }
}






================================================
FILE: 37_codechef_spell_bob.cpp
================================================
//
//  main.cpp
//  Lecture 37
//
//  Created by Prince  Kumar on 17/04/19.
//  Copyright © 2019 Prince  Kumar. All rights reserved.
//
//                      CODE-CHEF

//       --- **    Problems on Spell bob   ** ---       //


#include <iostream>
using namespace std;
int main()
{
    int T; cin>>T;
    while(T--)
    {
        string s1,s2; cin>>s1>>s2;
        int a[3]={0};  // b count
        for(int i=0;i<3;i++)  // 'b' present  or not
        {
            if(s1[i]=='b' || s2[i]=='b')
                a[i]=1;
        }
        int b_count=0;
        for(int i=0;i<3;i++)
        {
            if(a[i]==1)
                b_count++;
        }
        if(b_count<=1)
            cout<<"no"<<endl;
        else if(b_count==2)
        {
            int index=0;
            for(int i=0;i<3;i++)
            {
                if(a[i]==0)
                    index=i;
            }
            if(s1[index]=='o' || s2[index]=='o')
                cout<<"yes"<<endl;
            else
                cout<<"no"<<endl;
        }
        else if(b_count==3)
        {
            int o_count=0;
            for(int i=0;i<3;i++)
            {
                if(s1[i]=='o' || s2[i]=='o')
                    o_count++;
            }
            if(o_count==0)
                cout<<"no"<<endl;
            else
                cout<<"yes"<<endl;
        }
    }
}




================================================
FILE: 38_codechef_fits_square_in_triangle.cpp
================================================
//
//  main.cpp
//  CODECHEF
//
//  Created by Prince  Kumar on 14/05/19.
//  Copyright © 2019 Prince  Kumar. All rights reserved.
//   --- **  Fits square in the triangle ** ---

#include <iostream>
using namespace std;
int main()
{
    int T; cin>>T;
    while(T--)
    {
        int b; cin>>b;
        if(b==1 || b==2 ||b==3)
            cout<<"0"<<endl;
        else
        {
            if(b%2==0)  // for EVEN
            {
                int area = 0.5 * b *b;
                int res =  (area - b )/4;
                cout<<res<<endl;
            }
            else   // for ODD
            {
                b=b-1;
                int area = 0.5 * b *b;
                int res =  (area - b )/4;
                cout<<res<<endl;
            }
               
        }
    }
}


================================================
FILE: 39_codechef_chef_and_Eid.cpp
================================================
//
//  main.cpp
//  CODE-CHEF
//
//  Created by Prince  Kumar on 14/05/19.
//  Copyright © 2019 Prince  Kumar. All rights reserved.
//
// ---- ** Chef and Eid ** ------

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int T;cin>>T;
    while(T--)
    {
        int n ; cin>>n;
        vector<int > v;
        for(int i=0;i<n;i++)
        {
            // cin>>v[i];
            int x; cin>>x;
            v.push_back(x);
        }
        sort(v.begin(),v.end());
        // sort
        
        vector<int> res;
        for(int i=0;i<n-1;i++)
        {
            res.push_back(v[i+1]-v[i]);
        }
        sort(res.begin(),res.end());
        cout<<res[0]<<endl;
        
        
    }
}



================================================
FILE: 40_codechef_chef_judges_competition.cpp
================================================
//
//  main.cpp
//  CODE-CHEF
//
//  Created by Prince  Kumar on 15/05/19.
//  Copyright © 2019 Prince  Kumar. All rights reserved.
//
// ---- ** chef judges a competition ** --- //


#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int T;cin>>T;
    while(T--)
    {
        int n; cin>>n;
        int a[n] ; // for ALICE
        int b[n] ; // for BOB
        
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
        }
        
        for(int i=0;i<n;i++)
        {
            cin>>b[i];
        }
        
        // sorting in ARRAY
        sort(a,a+n);
        sort(b,b+n);
        
        int suma =0;
        int sumb = 0;
        
        for(int i=0;i<n-1;i++)
        {
            suma = suma + a[i];
            sumb = sumb + b[i];
        }
        // we get sum results
        
        if(suma==sumb)
            cout<<"Draw"<<endl;
        else if( suma < sumb)
            cout<<"Alice"<<endl;
        else
            cout<<"Bob"<<endl;
        
    }
}









================================================
FILE: 41_codechef_chef_and_glove.cpp
================================================
//
//  main.cpp
//  CODE-CHEF
//
//  Created by Prince  Kumar on 17/05/19.
//  Copyright © 2019 Prince  Kumar. All rights reserved.
//
//   ---- ** CHEF AND GLOVE ** ------- //


#include <iostream>
using namespace std;
int main()
{
    int T; cin>>T;
    while(T--)
    {
        int n; cin>>n;
        // numbering 1 to n
        
        int len[n+1];  // length of finger
        int glov [n+1]; // lenght of sheath
        
        for(int i=1;i<n+1;i++)
        {
            cin>>len[i];
        }
        for(int i=1;i<n+1;i++)
        {
            cin>>glov[i];
        }
        
        // front
        int front=0;
        for(int i=1;i<n+1;i++)  // loop runs n times
        {
            if(len[i]<=glov[i])
                front++;
        }
        
        // back
        int back=0;
        for(int i=1;i<n+1;i++)
        {
            if(len[i]<=glov[n+1-i])  // i=1 --> 8+1-1 = 8
                back++;                // i=2  --> 8+1-2 =7
        }
        
        if(front==n && back==n)
        {
            cout<<"both"<<endl;
        }
        else if(front!=n && back!=n )
            cout<<"none"<<endl;
        else if(front==n && back!=n)
            cout<<"front"<<endl;
        else if( front!=n && back ==n)
            cout<<"back"<<endl;
    }
}










================================================
FILE: 42_codechef_the_great_run.cpp
================================================
//
//  main.cpp
//  CODE-CHEF
//
//  Created by Prince  Kumar on 17/05/19.
//  Copyright © 2019 Prince  Kumar. All rights reserved.
//
//  ------ ** The Great Run ** ---------- //

#include <iostream>
using namespace std;
int main()
{
    int T; cin>>T;
    while(T--){
        
        int n,k; cin>>n>>k;
        int a[n];  // no. of girls per km
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
        }
        // we get values of girls
        
        int max=0;
        for(int i=0;i<=n-k;i++)
        {
            int sum=0;
            for(int j=i;j<i+k;j++)
            {
                sum+=a[j];
            }
            if(max<sum)
                max=sum;
        }
        cout<<max<<endl;
        
    }
}






================================================
FILE: 43_codechef_attendance.cpp
================================================
//
//  main.cpp
//  CODE-CHEF
//
//  Created by Prince  Kumar on 18/05/19.
//  Copyright © 2019 Prince  Kumar. All rights reserved.
//
// ------- ** Attendance ** --------- //

#include <iostream>
using namespace std;
int main()
{
    int T;cin>>T;
    while(T--)
    {
        int n; cin>>n;
        string f[n];
        string l[n];
        
        for(int i=0;i<n;i++)
        {
            cin>>f[i]>>l[i];  // first name and last name
        }
        
        int a[n];
        for(int i=0;i<n;i++){a[i]=0;}
        
        // initalise the array - a --> to 0
        
        for(int i=0;i<n-1;i++)
        {
            for(int j=i+1;j<n;j++)
            {
                if(f[i]==f[j])
                {a[i]++; a[j]++;}
            }
        }
        
        // we check the condition on array a
        
        for(int i=0;i<n;i++)
        {
            if(a[i]==0)
            {
                cout<<f[i]<<endl;
            }
            else
            {
                cout<<f[i]<<" "<<l[i]<<endl;
            }
        }
    }
}








================================================
FILE: 44_codechef_making_a_meal.cpp
================================================
//
//  main.cpp
//  CODE-CHEF
//
//  Created by Prince  Kumar on 18/05/19.
//  Copyright © 2019 Prince  Kumar. All rights reserved.
//
//  ------ ** Making a Meal ** -------- //

#include<iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int T;cin>>T;
    while(T--)
    {
        int n;cin>>n;
        int bowl[26]={0};
        for(int i=0;i<n;i++)
        {
            string s;cin>>s;
            for(int j=0;j<s.size();j++)
            {
                int x = s[j] - 97;
                bowl[x]++;
            }
        }
        // we get all letters
        
        vector<int> v;
        v.push_back(bowl[2]/2); // for 'c'
        v.push_back(bowl[3]/1);  // for 'd'
        v.push_back(bowl[4]/2);  // for 'e'
        v.push_back(bowl[5]/1);  // for 'f'
        v.push_back(bowl[7]/1);  // for 'h'
        v.push_back(bowl[14]/1);  // for 'o'
        
        sort(v.begin(),v.end());
        cout<<v[0]<<endl;
        
    }
}





================================================
FILE: 45_codechef_uncle_johny.cpp
================================================
//
//  main.cpp
//  lecture 45
//
//  Created by Prince  Kumar on 25/07/19.
//  Copyright © 2019 Prince  Kumar. All rights reserved.
//
// codechef question --** Uncle johny ** ---- //


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int T; cin>>T;
    while(T--)
    {
        int n; cin>>n;
        vector<int> v;
        for(int i=0;i<n;i++)
        {
            int x; cin>>x;
            v.push_back(x);
            // v.push_back(cin);
        }
        int k; cin>>k; // index of jhony unle song
        // vector use --> indexing start from 0
        int val  = v[k-1]; // uncle jhony
        sort(v.begin(),v.end());
        for(int i=0;i<n;i++)
        {
            if(v[i]==val)
            {
                cout<<i+1<<endl;
                break;
            }
        }
    }
}







================================================
FILE: 46_drink_codeforce.cpp
================================================
//
//  main.cpp
//  hello
//
//  Created by Prince  Kumar on 01/08/19.
//  Copyright © 2019 Prince  Kumar. All rights reserved.
//

#include <iostream>
using namespace std;
int main()
{
    int n; cin>>n;
    // p[i] =  how much ml of orange juice
    int p[n]; for(int i=0;i<n;i++)
    {
        int x ;cin>>x;
        x = x*10;
        p[i] = x;
    }
    // we calculate total orange juice
    
    int tot_orange  = 0;
    for(int i=0;i<n;i++)
    {
        tot_orange+=p[i];
    }
    
    double x = tot_orange*100.00;
    //  / we calculate total orange juice
    
    int tot_vol = n*1000; //integer
    
    // we calcuate total volume
    
    double res = (x/tot_vol);
    cout<<res<<endl;
    
     
}


================================================
FILE: 47_candles_codeforces.cpp
================================================
//
//  main.cpp
//  candles

// codeforces question
//                   A. New Year Candles


#include <iostream>
using namespace std;
int main()
{
    int a,b; cin>>a>>b;
    
    int x = a;
    while(a>=b)
    {
        x = x + (a/b);
        a = (a/b) + (a%b);
    }
    cout<<x<<endl;
    
}


================================================
FILE: 49_two_buttons_codeforces.cpp
================================================
//
//  main.cpp
//  Two Buttons

//
//  Created by Prince  Kumar on 13/08/19.
//  Copyright © 2019 Prince  Kumar. All rights reserved.
//

///             TWO BUTTONS --> Code-forces

#include <iostream>
using namespace std;
int main()
{
    int n,m; cin>>n>>m;
    if(n>=m)
    { // 10  1
        cout<<n-m<<endl;
    }
    else
    {
        // back tracking
        int count=0;
        while(m>n)
        {
            if(m%2==0)
            {m/=2; count++;}
            else
            {
                m+=1; count++;
            }
        }
        cout<<count+(n-m)<<endl;
    }
}


================================================
FILE: 50_vanya_and_books_codeforces.cpp
================================================
//
//  main.cpp
//  books
//
//  Created by Prince  Kumar on 15/08/19.
//  Copyright © 2019 Prince  Kumar. All rights reserved.
//    codeforce --> Vanya and Books

#include <iostream>
#include <math.h>
#define ll long long
using namespace std;
int main()
{
    ll int n; cin>>n;
    ll int a[13]={0};
    for(int i=1;i<13;i++)
    {
        a[i]=pow(10,i)-1;
    }
    for(int i=2;i<13;i++)
    {
        for(int j=1;j<=i-1;j++)
        {
            a[i] = a[i]-a[j];
        }
    }
//    for(int i=1;i<13;i++)
//    {
//        cout<<a[i]<<endl;
//    }
    // value in array is to set
    
    ll int count=0;
    for(int i=1;i<13;i++ )
    {
        if(n-a[i]>=0)
        {
            count+=a[i]*i;
            n=n-a[i];
        }
        else
        {
            count+=n*i;
            break;
        }
    }
    cout<<count<<endl;
    
}









================================================
FILE: 51_eleven_codeforces.cpp
================================================
//
//  main.cpp
//  eleven
//
//  Created by Prince  Kumar on 21/08/19.
//  Copyright © 2019 Prince  Kumar. All rights reserved.
//

//.      PROBLEMS --> ELEVEN from Codeforces

#include <iostream>
#include <cstring>
#define ll long long
using namespace std;
int main()
{
    ll int a[20]={0}; // store fibonacci series
    a[0]=a[1]=a[2]=1;
    for(int i=3;i<20;i++)
    {
        a[i]=a[i-1]+a[i-2];
    }
    //cout<<a[19]<<endl;
    // 1 1 2 3 5 8 ...  if n==10
    int n; cin>>n;
    int b[n+1]; memset(b,0,sizeof(b));
    
    
    // 1 represent 'O'
    // 0 represent 'o'
    for(int i=1;i<20;i++)
    {
        if(a[i]<=n)
        {
            b[a[i]]=1;
        }
    }
    for(int i=1;i<=n;i++)
    {
        if(b[i]==1)
            cout<<"O";
        else
            cout<<"o";
    }
    cout<<endl;
    
}





================================================
FILE: 52_codechef_flatland.cpp
================================================
//
//  main.cpp
//  faltland
//
//  Created by Prince  Kumar on 05/09/19.
//  Copyright © 2019 Prince  Kumar. All rights reserved.
//

//  Code Of "FLATLAND" codechef 
#include <iostream>
using namespace std;
int main()
{
    int a[36];
    for(int i=1;i<36;i++)
    {
        a[i]=i*i;
    }
    // we got a array of perfect square
    
    int T;cin>>T;
    while(T--)
    {
        int n;cin>>n;
        int count=0;
        while(n!=0)
        {
            for(int i=1;i<36;i++)
            {
                if(a[i]<=n && a[i+1]>n)
                {
                    n=n-a[i];
                unt++;
                }
            }
        }
        cout<<count<<endl;
    }
}




================================================
FILE: 53_codeforces_MUH_and_sticks.cpp
================================================
//
//  main.cpp
//  code
//
//  Created by Prince  Kumar on 07/09/19.
//  Copyright © 2019 Prince  Kumar. All rights reserved.
//
//  codeforces --> MUH and Sticks

#include <iostream>
using namespace std;
int main()
{
    int a[10]={0};
    for(int i=1;i<=6;i++)
    {
        int x; cin>>x;
        a[x]++;
    }
    
    int leg =0;
    int leg_value=0;
    for(int i=1;i<=9;i++)
    {
        if(a[i]>=4)
        {
            leg=1;
            leg_value=i;
            a[i]=a[i]-4;
            break;
        }
        
    }
    
    int body=0;
    int body_value=0;
    
    for(int i=1;i<=9;i++)
    {
        if(a[i]>=1)
        {
            body=1;
            body_value=i;
            a[i]=a[i]-1;
            break;
        }
        
    }
    
    int head=0;
    int head_value=0;
    
    for(int i=1;i<=9;i++)
    {
        if(a[i]>=1)
        {
            head=1;
            head_value=i;
            a[i]=a[i]-1;
            break;
        }
        
    }
    
    // we got leg leg_value / body body_value / head head_value
    
    if(leg==1 && body==1 && head==1)
    {
        if(leg_value!=head_value && leg_value!=body_value && head_value!=body_value)
            cout<<"Bear"<<endl;
        else if(body_value!=head_value && (leg_value!=head_value || leg_value!=body_value))
            cout<<"Bear"<<endl;
        else if(leg_value!=head_value && leg_value!=body_value && head_value==body_value)
            cout<<"Elephant"<<endl;
        else if(leg_value==head_value && leg_value==body_value && head_value==body_value)
            cout<<"Elephant"<<endl;
    }
    else
        cout<<"Alien"<<endl;
}


================================================
FILE: 54_print_subset_of_size_k_of_array.cpp
================================================
//
//  main.cpp
//  subset
//
//  Created by Prince  Kumar on 09/09/19.
//  Copyright © 2019 Prince  Kumar. All rights reserved.
//
//      Print all subset of size 'k' of array of size 'n'

#include <iostream>
#include<vector>
#include <math.h>
#include <algorithm>
using namespace std;
int main()
{
    cout<<"Enter number of elemnets in array : "<<endl;
    int n; cin>>n;
    cout<<"Enter the size of subset : "<<endl;
    int k ; cin>>k;
    
    int a[n];
    cout<<"Enter the numbers : "<<endl;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=1;i<pow(2,n);i++)
    {
        vector<int> v;
        int x=i; // x=8
        while(x>0)
        {
            int z = x%2;  //  0  0  0   1
            v.push_back(z);
            x=x/2;  // 4  2  1 0
        }
        int p  = n- (int)v.size();
        for(int j=1;j<=p;j++)
        {
            v.push_back(0);
        }
        reverse(v.begin(), v.end());
        int count=0;
        for(int i=0;i<v.size();i++)
        {
            if(v[i]==1)
                count++;
        }
        if(count==k)
        {
            for(int i=0;i<v.size();i++)
            {
                if(v[i]==1)
                {
                    cout<<a[i]<<" ";
                }
            }
            cout<<endl;
        }
        v.clear();
        
    }
}


================================================
FILE: 55_codechef_Easy_Fibonacci.cpp
================================================
//
//  main.cpp
//  fibonacciii
//
//  Created by Prince  Kumar on 23/09/19.
//  Copyright © 2019 Prince  Kumar. All rights reserved.
//
//  code of Easy Fibonacci

#include <iostream>
#include <math.h>
using namespace std;
int main()
{
    int T; cin>>T;
    while(T--)
    {
        long long int x; cin>>x;
        long long int z = log2((long double)x);
        if(z==0)
            cout<<"0"<<endl;
        else if(z==1)
            cout<<"1"<<endl;
        else
        {
            int a = z%4;
            if(a==2)
                cout<<"2"<<endl;
            else if(a==3)
                cout<<"3"<<endl;
            else if(a==0)
                cout<<"0"<<endl;
            else if(a==1)
                cout<<"9"<<endl;
        }
    }
}






================================================
FILE: 56_codechef_Chef_and_Interesting_Subsequences.cpp
================================================
//
//  main.cpp
//  code
//
//  Created by Prince  Kumar on 23/09/19.
//  Copyright © 2019 Prince  Kumar. All rights reserved.
//
//  code of Chef and Interesting Subsequences
//  ** --- September long challenge  -- ** //

#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
ll int gcd(ll int a, ll int b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
void nCr(int n, int r)
{
    
    // p holds the value of n*(n-1)*(n-2)...,
    // k holds the value of r*(r-1)...
    long long p = 1, k = 1;
    
    // C(n, r) == C(n, n-r),
    // choosing the smaller value
    if (n - r < r)
        r = n - r;
    
    if (r != 0) {
        while (r) {
            p *= n;
            k *= r;
            
            // gcd of p, k
            long long m = gcd(p, k);
            
            // dividing by gcd, to simplify product
            // division by their gcd saves from the overflow
            p /= m;
            k /= m;
            
            n--;
            r--;
        }
        
        // k should be simplified to 1
        // as C(n, r) is a natural number
        // (denominator should be 1 ) .
    }
    
    else
        p = 1;
    
    // if our approach is correct p = ans and k =1
    cout << p << endl;
}
int main()
{
    int T; cin>>T;
    while(T--)
    {
        vector<int> v;
        int n,k;cin>>n>>k;
        for(int i=0;i<n;i++)
        {
            int x; cin>>x;
            v.push_back(x);
        }
        sort(v.begin(),v.end());
        int last_index_of_k = v[k-1];
        int count=0;
        for(int i=0;i<n;i++)
        {
            if(v[i]==last_index_of_k)
                count++;
        }
        // we get total number of last_element
        
        int num=0;
        for(int i=0;i<k;i++)
        {
            if(v[i]==last_index_of_k)
                num++;
        }
        nCr(count,num);  // countCnum
        
    }
}










================================================
FILE: 57_codechef_A-books.cpp
================================================
//
//  main.cpp
//  jdjd
//
//  Created by Prince  Kumar on 26/09/19.
//  Copyright © 2019 Prince  Kumar. All rights reserved.
//
//   --- codechef --> A-Books ---
#include <iostream>
using namespace std;
int main()
{
    int T; cin>>T;
    while(T--)
    {
        int n; cin>>n;
        int a[n];
        int b[1000001]={0};
        // in b[]  we store last index of elements
        for(int i=0;i<n;i++)  // i->index
        {
            int x; cin>>x;
            a[i]=x;
            b[x]=i;
            
//            cin>>a[i];
//            b[a[i]]=i;
        }
        for(int i=0;i<n;i++)
        {
            //cout<<n-1-b[a[i]]<<endl;
            int x = a[i];
            int last_index = b[x];
            cout<<n-1-last_index<<" ";
        }
        cout<<endl;
        
    }
}





================================================
FILE: 58_codechef_phone_prices.cpp
================================================
//
//  main.cpp
//  test1
//
//  Created by Prince  Kumar on 06/10/19.
//  Copyright © 2019 Prince  Kumar. All rights reserved.
//

//                                 **-- October Long Challenge --**
//                                       **-- Phone prices --**

#include <iostream>
using namespace std;
int main()
{
    int T; cin>>T;
    while(T--)
    {
        int n; cin>>n;
        int a[n+1]; for(int i=1;i<=n;i++){cin>>a[i];}
        // we have now prices on respective days
        int count=1;
        for(int i=2;i<=n;i++)
        {
            int price = a[i];
            if(i==2)
            {
                if(price<a[i-1])
                    count++;
            }
            else if(i==3)
            {
                if(price<a[i-1] && price<a[i-2])
                    count++;
            }
            else if(i==4)
            {
                if(price<a[i-1] && price<a[i-2] && price<a[i-3])
                    count++;
            }
            else if(i==5)
            {
                if(price<a[i-1] && price<a[i-2] && price<a[i-3] && price<a[i-4])
                    count++;
            }
            else
            {
                if(price<a[i-1] && price<a[i-2] && price<a[i-3] && price<a[i-4] && price<a[i-5])
                    count++;
            }
        }
        cout<<count<<endl;
    }
}


================================================
FILE: 59_codechef_operations_on_a_matrix.cpp
================================================
//
//  main.cpp
//  bbcfjc
//
//  Created by Prince  Kumar on 06/10/19.
//  Copyright © 2019 Prince  Kumar. All rights reserved.
//

//                              ***-- October Long Challeneg 2019 --***
/                                      ***-- Operations on a Matrix --****

#include <iostream>
#include <cstring>
#include <string>
#include <string.h>
#define ll long long
using namespace std;
int main()
{
    ll int T; cin>>T;
    while(T--)
    {
        ll int n,m,q;cin>>n>>m>>q;
        ll int a[n+1]; memset(a,0,sizeof(a)); // row
        ll int c[m+1]; memset(c,0,sizeof(c)); // column
        for(ll int i=0;i<q;i++)
        {
            ll int a1, a2;cin>>a1>>a2;
            a[a1]++; c[a2]++;
        }
        ll int odd=0,even=0,a_zero=0;
        for(ll int i=1;i<=n;i++)
        {// row
            
            if(a[i]>0)
            {
            if(a[i]%2!=0)
                odd++;
            else
                even++;
                
            }
            else
                a_zero++;
        }
        // for column
        ll int count=0;
        for(ll int i=1;i<=m;i++)
        {
            if(c[i]>0)
            {
                if(c[i]%2!=0)
                {
                    count+=even+a_zero;
                }
                else
                {
                    // even
                    count+=odd;
                }
            }
            else
                count+=odd;
        }
        cout<<count<<endl;
        
    }
}


================================================
FILE: 60_Adding_one_to_the_numbers.cpp
================================================
//
//  main.cpp
//
//  Created by Prince  Kumar on 16/04/20.
//  Copyright © 2020 Prince  Kumar. All rights reserved.
//
//                      ---** ADD ONE TO THE NUMBER **---

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    cout<<"Enter The size of Vector : "<<endl;
    int n; cin>>n;
    
    vector<int> v; v.push_back(0);
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        v.push_back(x);
    }
    
    // check conditions
    int k = (int)v.size() - 1;
    
    if(v[k]<9){
        v[k]+=1;  // v[k] = v[k] + 1;
    }else{
        
        while(v[k]==9){
            v[k]=0;
            k= k-1;
        }
        
        v[k]= v[k]+1;
    }
    
    // Print the result
    // we have to omit the leading zero's
    
    int s = 0;
    for(int i=0;i<(int)v.size() ;i++){
        if(v[i]!=0){
            s=i;  // here we store index
            break;
        }
    }
    
    for (int i=s;i<(int)v.size();i++){
        cout<<v[i]<<" ";
    }
    cout<<endl;
}


================================================
FILE: Chef and Price Control.cpp
================================================
//
//  COMPETITIVE PROGRAMMING .cpp
//
//  Created by Prince  Kumar on 15/06/2020.
//  Copyright © 2020 Prince  Kumar. All rights reserved.
//
//                       ---** COMPETITIVE PROGRAMMING in C++ **---
//                            ---** PRACTICE CODING SKILLS **---


#include <iostream>
using namespace std;
int main(){
    int T; cin>>T;
    while(T--){
        int n, k; cin>>n>>k;
        int prev_amt=0;
        int ori_amt=0;
        // 2 3 4 7 10     5
        for(int i=0;i<n;i++){
            int x; cin>>x;   // x = 2
            prev_amt+=x;  // profit initially   prev_Amt = 2
            
            if(x>k){
                x=k;
            }               // x= 5
            ori_amt+=x;    // ori_amt = 2
        }
        cout<<prev_amt-ori_amt<<endl;
        
//        int a[n];
//        for(int i=0;i<n;i++){
//            cin>>a[i];
//            prev_amt+=a[i];
//        }
//        for(int i=0;i<n;i++){
//            if(a[i]>k){
//                a[i]=k;
//            }
//            ori_amt+=a[i];
//        }
    }
}


================================================
FILE: Data Structures/Add a node at the Middle of linked list.cpp
================================================
//
//  DATA STRUCTURES.cpp
//
//  Created by Prince  Kumar on 23/05/2020.
//  Copyright © 2020 Prince  Kumar. All rights reserved.
//
//                 ---** INSERTION OF NODE IN  LINKED LIST in C++ **---

//                         ---** PRACTICE CODING SKILLS **---


#include <iostream>
using namespace std;

/* ----- Linked list Node  ------ */
struct node{
    int data;
    node *next;
};

/* -------  Print the Linked List  -------*/
void printList (node *n){
    int count=0;
    while(n!=NULL){
        cout<<n->data<<endl;
        n = n->next;
        count++;
    }
    cout<<"No. of element in linked list is : "<<count<<endl;
}

/* ------  INSERTION OF NODE AT FRONT OF LINKED LIST --------*/

void push(node **head_ref , int newData){
    node *newNode = new node();
    newNode -> data = newData;
    newNode -> next = *head_ref;
    *head_ref = newNode;
}

/* ------  INSERTION OF NODE AT MIDDLE OF LINKED LIST --------*/

void insertAfter(node *prev_node , int newData){
    node *newNode = new node();
    newNode->data = newData;
    newNode->next = prev_node->next;
    prev_node->next = newNode;
}

int main(){
   
    node *head = NULL;
    push(&head , 5);
    push(&head , 7);
    push(&head , -3);
    // -3 7 5
    
    insertAfter(head->next,79);
    
    printList(head);
    
}


================================================
FILE: Data Structures/Add a node at the end of linked list.cpp
================================================
//
//  DATA STRUCTURES.cpp
//
//  Created by Prince  Kumar on 24/05/2020.
//  Copyright © 2020 Prince  Kumar. All rights reserved.
//
//                 ---** INSERTION OF NODE IN  LINKED LIST in C++ **---

//                         ---** PRACTICE CODING SKILLS **---


#include <iostream>
using namespace std;

/* ----- Linked list Node  ------ */
struct node{
    int data;
    node *next;
};

/* -------  Print the Linked List  -------*/
void printList (node *n){
    int count=0;
    while(n!=NULL){
        cout<<n->data<<endl;
        n = n->next;
        count++;
    }
    cout<<"No. of element in linked list is : "<<count<<endl;
}

/* ------  INSERTION OF NODE AT FRONT OF LINKED LIST --------*/

void push(node **head_ref , int newData){
    node *newNode = new node();
    newNode -> data = newData;
    newNode -> next = *head_ref;
    *head_ref = newNode;
}

/* ------  INSERTION OF NODE AT MIDDLE OF LINKED LIST --------*/

void insertAfter(node *prev_node , int newData){
    node *newNode = new node();
    newNode->data = newData;
    newNode->next = prev_node->next;
    prev_node->next = newNode;
}

/* ------  INSERTION OF NODE AT END OF LINKED LIST --------*/


void append(node **head_ref, int newData){
    
    node *newNode = new node();
    newNode->data = newData;
    newNode->next = NULL;
    
    node *last = *head_ref;
    
    if(*head_ref == NULL){
        *head_ref = newNode;
        return;
    }
    
    while(last->next != NULL){
        last = last->next;
    }
    
    last->next = newNode;
    return;
    
}

int main(){
   
    node *head = NULL;
    push(&head , 5);
    push(&head , 7);
    push(&head , -3);
    // -3 7 5
    
    insertAfter(head->next,79);
    // -3 7 79 5
    
    append(&head, 90);
    printList(head);
    
}




================================================
FILE: Data Structures/Add a node at the front of linked list.cpp
================================================

//  DATA STRUCTURES.cpp
//
//  Created by Prince  Kumar on 22/05/2020.
//  Copyright © 2020 Prince  Kumar. All rights reserved.
//
//                 ---** INSERTION OF NODE IN  LINKED LIST in C++ **---

//                         ---** PRACTICE CODING SKILLS **---


#include <iostream>
using namespace std;

/* ----- Linked list Node  ------ */
struct node{
    int data;
    node *next;
};

/* -------  Print the Linked List  -------*/
void printList (node *n){
    int count=0;
    while(n!=NULL){
        cout<<n->data<<endl;
        n = n->next;
        count++;
    }
    cout<<"No. of element in linked list is : "<<count<<endl;
}

//node *push(node *head , int newData){
//    node *newNode = new node();
//    newNode -> data = newData;
//    newNode -> next = head;
//    head = newNode;
//    return head;
//}

void push(node **head_ref , int newData){
    node *newNode = new node();
    newNode -> data = newData;
    newNode -> next = *head_ref;
    *head_ref = newNode;
}

int main(){
   
    node *head = NULL;
    push(&head , 5);
    push(&head , 7);
    push(&head , -3);
    
    printList(head);
    
}





================================================
FILE: Data Structures/Array_in_data_structures.cpp
================================================
//
//  DATA STRUCTURES.cpp
//
//  Created by Prince  Kumar on 08/05/2020.
//  Copyright © 2020 Prince  Kumar. All rights reserved.
//
//                      ---** ARRAYS in C++ **---

#include <iostream>
using namespace std;
int main(){
    
    //1st method
//    int arr[5];
//    arr[0] = 4;
//    arr[1] = 3;
//    arr[2] = -10;
//    arr[3] = 8;
//    arr[4] = -6;
    
    // 2nd method
    int arr[5] = {4 , 3, -10, 8,-9};
    
    int arr1[] = {4 , 3, -10, 8,7 , 4, 2 , 11};
    //int arr2[];
    
    
    cout<<arr[3]<<endl;
    cout<<arr1[5]<<endl;
    cout<<"Ans : "<<arr1[3/2]<<endl;
    
    
    int a[5]={0};
    cout<<a[4]<<endl;
    
//    int b[5]={1};
//    cout<<b[3]<<endl;
}





================================================
FILE: Data Structures/Circular Linked List data_structure.cpp
================================================
//
//  DATA STRUCTURES.cpp
//
//  Created by Prince  Kumar on 20/05/2020.
//  Copyright © 2020 Prince  Kumar. All rights reserved.
//
//                      ---** CIRCULAR LINKED LIST in C++ **---

//                     ---** PRACTICE CODING SKILLS **---


#include <iostream>
using namespace std;

//Linked list Node
struct node{
    int data;
    node *next;
};

void printList (node *n){
    int count=0;
    while(n!=NULL){
        cout<<n->data<<endl;
        n = n->next;
        count++;
    }
    cout<<"No. of element in linked list is : "<<count<<endl;
}

void printCircularList(node * first){
    node *temp = first;
    
    if(first!=NULL){
        cout<<temp->data<<endl;
        temp = temp->next;  // this changes in temp
        
        while(temp != first){
            cout<<temp->data<<endl;
            temp = temp->next;
        }
    }
}

int main(){
    
//    /*                   Make A linked List                            */
    node *head  = new node(); node *second = new node(); node *third = new node();
    node *four  = new node(); node *five = new node(); node *six = new node();
    node *seven  = new node(); node *eight = new node(); node *nine = new node();

    head -> data = 5;   head -> next = second;
    second->data = 1;   second ->next = third;
    third -> data = -3; third ->next = four;
    four -> data = 11;  four -> next = five;
    five->data = 10;    five ->next = six;
    six -> data = 2;    six ->next = seven;
    seven -> data = 7;  seven -> next = eight;
    eight->data = 9;    eight ->next = nine;
    nine -> data = 18;  nine ->next = head;

    printCircularList(four);
}


================================================
FILE: Data Structures/Delete a node of a linked list.cpp
================================================
//
//  DATA STRUCTURES.cpp
//
//  Created by Prince  Kumar on 25/05/2020.
//  Copyright © 2020 Prince  Kumar. All rights reserved.
//
//                 ---** DELETION OF NODE IN  LINKED LIST in C++ **---
//                         ---** PRACTICE CODING SKILLS **---


#include <iostream>
using namespace std;

/* ----- Linked list Node  ------ */
struct node{
    int data;
    node *next;
};

/* -------  Print the Linked List  -------*/
void printList (node *n){
    int count=0;
    while(n!=NULL){
        cout<<n->data<<endl;
        n = n->next;
        count++;
    }
    cout<<"No. of element in linked list is : "<<count<<endl;
}

/* ------  INSERTION OF NODE AT FRONT OF LINKED LIST --------*/

void push(node **head_ref , int newData){
    node *newNode = new node();
    newNode -> data = newData;
    newNode -> next = *head_ref;
    *head_ref = newNode;
}

/* ------  DELETION OF NODE IN LINKED LIST --------*/


void deleteNode(node **head_ref , int key){
    // initialise prev and temp
    node *prev, *temp;
    
    //store head to the temp;
    temp  = *head_ref;
    
    //if key is present in head
    if(temp!=NULL && temp->data == key){
        *head_ref = temp->next;
        free(temp);
        return;
    }
    
    //we traverse the linkedlist and keep track og prev node
    // because we have to perform prev->next
    
    while(temp!=NULL && temp->data!=key){
        prev=temp;
        temp = temp->next;
    }
    
    // we travserse whole linked list and we didn't got the key
    if(temp==NULL) return;
    
    // but, if we found the key
    prev->next = temp->next;
    free(temp);
}


int main(){
   
    node *head = NULL;
    push(&head , 5);
    push(&head , 7);
    push(&head , -3);
    push(&head , 2);
    push(&head , 9);
    
    printList(head);
    
    deleteNode(&head, 2);
    
    printList(head);
    
    
}


================================================
FILE: Data Structures/Doubly Linked list.cpp
================================================
//
//  DATA STRUCTURES.cpp
//
//  Created by Prince  Kumar on 27/05/2020.
//  Copyright © 2020 Prince  Kumar. All rights reserved.
//
//                 ---** INSETION OF NODE IN DOUBLY LINKED LIST in C++ **---
//                         ---** PRACTICE CODING SKILLS **---


#include <iostream>
using namespace std;

/* ----- Doubly Linked list Node  ------ */
struct node{
    int data;
    node *next;
    node *prev;
};


/*-------  Print the Douubly Linked List  ------- */
void printList (node *n){
    int count=0;
    while(n!=NULL){
        cout<<n->data<<endl;
        n = n->next;
        count++;
    }
    cout<<"No. of element in Doubly linked list is : "<<count<<endl;
}

/*-------  Insert node in Doubly Linked List  ------- */

void push(node **head_ref, int new_data){
    
    node *new_node = new node();
    new_node->data=  new_data;
    new_node->next = *head_ref;
    new_node->prev = NULL;
    
    if((*head_ref) != NULL){
        (*head_ref)->prev = new_node;
    }
    
    (*head_ref) = new_node;
}


int main(){
    
    node *head= NULL;
    push(&head, 4);
    push(&head, 11);
    push(&head, -3);
    
    // -3 11 4
    
    printList(head);
}



================================================
FILE: Data Structures/Find the middle of a given linked list.cpp
================================================
//
//  DATA STRUCTURES.cpp
//
//  Created by Prince  Kumar on 20/05/2020.
//  Copyright © 2020 Prince  Kumar. All rights reserved.
//
//                      ---** LINKED LIST in C++ **---

//                     ---** PRACTICE CODING SKILLS **---


#include <iostream>
using namespace std;

//Linked list Node
struct node{
    int data;
    node *next;
};

void printList (node *n){
    int count=0;
    while(n!=NULL){
        cout<<n->data<<endl;
        n = n->next;
        count++;
    }
    
    cout<<"No. of element in linked list is : "<<count<<endl;
}

void printMiddleElement( node *head){
    node *slow_ptr = head;
    node *fast_ptr = head;
    
    if(head!=NULL){
        while(fast_ptr!=NULL && fast_ptr->next!=NULL){
            fast_ptr = fast_ptr->next->next;
            slow_ptr = slow_ptr->next;
        }
        cout<<"Middle Element is : "<<slow_ptr->data<<endl;
    }
    
}

int main(){
    
    /*                   Make A linked List                            */
    node *head  = new node(); node *second = new node(); node *third = new node();
    node *four  = new node(); node *five = new node(); node *six = new node();
    node *seven  = new node(); node *eight = new node(); node *nine = new node();
    
    head -> data = 5;   head -> next = second;
    second->data = 1;   second ->next = third;
    third -> data = -3; third ->next = four;
    four -> data = 11;  four -> next = five;
    five->data = 10;    five ->next = six;
    six -> data = 2;    six ->next = seven;
    seven -> data = 7;  seven -> next = eight;
    eight->data = 9;    eight ->next = nine;
    nine -> data = 18;  nine ->next = NULL;
    
    
    //printList(head);
    
//    node *start = head;
//    for(int i=0;i<5;i++){
//        cout<<start->data<<endl;
//        start= start->next;
//    }
    
    printMiddleElement(head);
}


================================================
FILE: Data Structures/Insert Node at the End of Doubly Linked List.cpp
================================================
//
//  DATA STRUCTURES.cpp
//
//  Created by Prince  Kumar on 30/05/2020.
//  Copyright © 2020 Prince  Kumar. All rights reserved.
//
//                 ---** INSETION OF NODE IN DOUBLY LINKED LIST in C++ **---
//                         ---** PRACTICE CODING SKILLS **---


#include <iostream>
using namespace std;

/* ----- Doubly Linked list Node  ------ */
struct node{
    int data;
    node *next;
    node *prev;
};


/*-------  Print the Doubly Linked List  ------- */
void printList (node *n){
    int count=0;
    while(n!=NULL){
        cout<<n->data<<endl;
        n = n->next;
        count++;
    }
    cout<<"No. of element in Doubly linked list is : "<<count<<endl;
}

/*-------  Insert node in Front of Doubly Linked List  ------- */

void push(node **head_ref, int new_data){
    
    node *new_node = new node();
    new_node->data=  new_data;
    new_node->next = *head_ref;
    new_node->prev = NULL;
    
    if((*head_ref) != NULL){
        (*head_ref)->prev = new_node;
    }
    
    (*head_ref) = new_node;
}

/*-------  Insert node in Middle of Doubly Linked List  ------- */

void insertAfter(node *prev_node, int new_data){
    
    if(prev_node == NULL){
        cout<<"given prev node can't be null"<<endl;
        return;
    }
    
    node *new_node = new node();
    new_node->data = new_data;
    new_node->next = prev_node->next;
    
    prev_node->next = new_node;
    new_node->prev = prev_node;
    
    if(new_node->next != NULL){
        new_node->next->prev = new_node;
    }
}

/*-------  Insert node in End of Doubly Linked List  ------- */

void append(node **head_ref, int new_data){
    node *new_node = new node();
    new_node->data = new_data;
    new_node->next = NULL;
    
    node *last  = *head_ref;  //head
    if(*head_ref == NULL){
        new_node->prev = NULL;
        *head_ref = new_node;
        return;
    }
    
    while(last->next != NULL){
        last = last->next;
    }
    
    last->next = new_node;
    new_node->prev = last;
    
    return;
}


int main(){
    
    node *head= NULL;
    push(&head, 4);
    push(&head, 11);
    push(&head, -3);
    // -3 11 4
    
    insertAfter(head->next, 10);
    // -3 11 10 4
    
    append(&head, 9);
    // -3 11 10 4 9
    
    printList(head);
}


================================================
FILE: Data Structures/Insert Node in Middle of Doubly Linkedlist.cpp
================================================
//
//  DATA STRUCTURES.cpp
//
//  Created by Prince  Kumar on 30/05/2020.
//  Copyright © 2020 Prince  Kumar. All rights reserved.
//
//                 ---** INSETION OF NODE IN DOUBLY LINKED LIST in C++ **---
//                         ---** PRACTICE CODING SKILLS **---


#include <iostream>
using namespace std;

/* ----- Doubly Linked list Node  ------ */
struct node{
    int data;
    node *next;
    node *prev;
};


/*-------  Print the Doubly Linked List  ------- */
void printList (node *n){
    int count=0;
    while(n!=NULL){
        cout<<n->data<<endl;
        n = n->next;
        count++;
    }
    cout<<"No. of element in Doubly linked list is : "<<count<<endl;
}

/*-------  Insert node in Front of Doubly Linked List  ------- */

void push(node **head_ref, int new_data){
    
    node *new_node = new node();
    new_node->data=  new_data;
    new_node->next = *head_ref;
    new_node->prev = NULL;
    
    if((*head_ref) != NULL){
        (*head_ref)->prev = new_node;
    }
    
    (*head_ref) = new_node;
}

/*-------  Insert node in Middle of Doubly Linked List  ------- */

void insertAfter(node *prev_node, int new_data){
    
    if(prev_node == NULL){
        cout<<"given prev. node can't be null"<<endl;
        return;
    }
    
    node *new_node = new node();
    new_node->data = new_data;
    new_node->next = prev_node->next;
    
    prev_node->next = new_node;
    new_node->prev = prev_node;
    
    if(new_node->next != NULL){
        new_node->next->prev = new_node;
    }
}

int main(){
    
    node *head= NULL;
    push(&head, 4);
    push(&head, 11);
    push(&head, -3);
    // -3 11 4
    
    insertAfter(head->next, 10);
    // -3 11 10 4
    
    printList(head);
}


================================================
FILE: Data Structures/LinkedList_Code_Practice.cpp
================================================
//
//  DATA STRUCTURES.cpp
//
//  Created by Prince  Kumar on 15/05/2020.
//  Copyright © 2020 Prince  Kumar. All rights reserved.
//
//                      ---** LINKED LIST in C++ **---

//                     ---** PRACTICE CODING SKILLS **---


#include <iostream>
using namespace std;

//Linked list Node
struct node{
    int data;
    node *next;
};

void printList (node *n){
    while(n!=NULL){
        cout<<n->data<<endl;
        n = n->next;
    }
}

int main(){
    node *head = new node();
    node *second = new node();
    node *third = new node();
    
    head -> data = 5;
    head -> next = second;
    
    second->data = 1;
    second ->next = third;
    
    third -> data = 3;
    third ->next = NULL;
    
    printList(head);

}


================================================
FILE: Data Structures/Vectors_in_STL_data_structure.cpp
================================================
//
//  DATA STRUCTURES.cpp
//
//  Created by Prince  Kumar on 3/06/2020.
//  Copyright © 2020 Prince  Kumar. All rights reserved.
//
//                 ---** STANDARD TEMPLATE LIBRARY (STL) in C++ **---
//                         ---** PRACTICE CODING SKILLS **---


#include <iostream>
#include <vector>
using namespace std;
int main(){
    vector<int> v;    /*  3 10 7*/
    vector<int> :: iterator it;
    v.push_back(3);
    v.push_back(10);
    v.push_back(7);
    
    auto a = v.begin();   // it provides iterator which points first element of vector
    cout<<"first element  : "<<a[0]<<endl;
    //v.pop_back();
    
    it = v.begin();
    cout<<"iterator points : "<<it[0]<<endl;
    
    it = v.end();
    //cout<<it<<endl;
    
    int size = (int)v.size();

    for(int i=0;i<size;i++){
        cout<<v[i]<<" ";
    }
    cout<<endl;
}




================================================
FILE: Data Structures/main.cpp
================================================
main file


================================================
FILE: Data Structures/structure_in_c++.cpp
================================================
//
//  DATA STRUCTURES.cpp
//
//  Created by Prince  Kumar on 11/05/2020.
//  Copyright © 2020 Prince  Kumar. All rights reserved.
//
//                      ---** STRUCTURE & CLASSES in C++ **---

#include <iostream>
using namespace std;
struct student{
  
    int roll;
    string name;
    int age;
    
    void studentDetails(){
        cout<<"name is : "<<name<<endl;
        cout<<"age is : "<<age<<endl;
        cout<<"roll is : "<<roll<<endl;
    }
    
};
int main(){
    
//    struct student prince;
    student simran;
    student prince;
    prince.age= 21;
    prince.name = "prince";
    prince.roll = 44;
    
    struct student prateek = { 21, "prateek" ,20};
    
    prince.studentDetails();
    cout<<endl;
    prateek.studentDetails();
    cout<<endl;
    
    
}


================================================
FILE: Kadane's_algorithm.cpp
================================================
//
//  main.cpp
//
//  Created by Prince  Kumar on 21/04/20.
//  Copyright © 2020 Prince  Kumar. All rights reserved.
//
//                      ---** MAX SUM CONTIGUOUS SUBARRAY **---

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    cout<<"Enter the size of Array : "<<endl;
    int n; cin>>n;
    
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    
    int max_so_far = a[0], max_ending_here =0;  // It store sum
    int start = 0 , end=0 , s=0;  // it store index
    
    for(int i=0;i<n;i++){
        max_ending_here+=a[i];
        if(max_so_far < max_ending_here){
            max_so_far=max_ending_here;
            start = s; end=i;
        }
        
        if(max_ending_here<0){
            max_ending_here = 0;
            s = i+1;
        }
    }
    
    int sum=0;
    for(int i=start ;i<=end ; i++){
        sum+=a[i];
        cout<<a[i]<<" ";
        
    }
    cout<<endl;
    cout<<sum<<endl;
    
    
}


================================================
FILE: Lecture - 15.cpp
================================================
//
//  main.cpp
//  lecture 15
//
//  Created by Prince  Kumar on 14/03/19.
//  Copyright © 2019 Prince  Kumar. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    vector<int > v;
    v.push_back(10);
    v.push_back(23);
    v.push_back(22);
    v.push_back(78);
    v.push_back(98);
    
    // iterators // pointers
    
    // sort // ascending to descending...
    sort(v.begin(),v.end());  // important
    
    v.pop_back();
    int k  = (int)v.size();   // k=5
    
    
    
    
    for(int i=0;i<k;i++)
    {
        cout<<v[i]<<" ";
    }
    cout<<endl;
    
}


================================================
FILE: Lecture - 16.cpp
================================================
//
//  main.cpp
//  lecture -16
//
//  Created by Prince  Kumar on 15/03/19.
//  Copyright © 2019 Prince  Kumar. All rights reserved.
//

#include <iostream>
#include <sstream>
using namespace std;
int main()
{
    int T; cin>>T;
    while(T--)
    {
        int n; cin>>n;    // int n= 7929024
        ostringstream str1;
        str1<<n;
        string s = str1.str();
        
        // single char  'a', '3' ' $'
        // set of char == string  == "prince"  , "78292"
        // string  s = 7929024    k = 7
        // find the string size
        int count=0;
        int k = (int)s.size();
        for(int i=0;i<k;i++)
        {
            if(s[i]=='4')
                count++;
            else
                count=count;
        }
        cout<<count<<endl;
    }
}


================================================
FILE: Lecture - 17.cpp
================================================
//
//  main.cpp
//  lecture -17
//
//  Created by Prince  Kumar on 17/03/19.
//  Copyright © 2019 Prince  Kumar. All rights reserved.
//

#include <iostream>
using namespace std;
int main()
{
    int T; cin>>T;
    while(T--)
    {
        int a,b,c,d; cin>>a>>b>>c>>d;
        if((a==c && b==d)|| (a==b && c==d)||(a==d && c==b))
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
}


================================================
FILE: Lecture - 18.cpp
================================================
#include <iostream>
using namespace std;
int main()
{
    int T;cin>>T;
    while(T--)
    {
        int n; cin>>n;
        int k ; cin>>k;
        string s; cin>>s;
        int cap=0;
        int small=0;
        for(int i=0;i<n;i++)
        {
            char x = s[i];
            int p = int(x); // ASCII CODE
            // CAPITAL   ASCII    65 to 90
            // SMALL     ASCII    97  to 122
            if(p>=65 && p<=90)
                cap++;
            else
                small++;
        }
        // we have no. of small and capital letters.
        if(cap==small)
        {
            if(k>=cap)
                cout<<"both"<<endl;
            else if(k<cap)
                cout<<"none"<<endl;
        }
        else if(small>cap)
        {
            if(k>=small)
                cout<<"both"<<endl;
            else if(k<cap)
                cout<<"none"<<endl;
            else
                cout<<"chef"<<endl;
                
        }
        else if(cap>small)
        {
            if(k>=cap)
                cout<<"both"<<endl;
            else if(k<small)
                cout<<"none"<<endl;
            else
                cout<<"brother"<<endl;
        }
    }
}


================================================
FILE: Lecture - 19.cpp
================================================

// ** -- code of "Studying alphabet " --Code chef -- **
#include <iostream>
using namespace std;
int main()
{
    string s; cin>>s;
    int a[26]={0}; // we put the value 0 in all the blocks
    int len = (int)s.size();  // length of string
    for(int i=0;i<len;i++)
    {
        char x = s[i]; // lets suppose x ='c'
        int p = int(x); // p =99
        p = p-97;  // index of that character // p =2
        a[p]=1;
    }
    int n; cin>>n;
    for(int i=0;i<n;i++)
    {
        int count=0;  // no. of charcter that not present in string s
        string k; cin>>k;  // k--> words
        for(int j=0;j<k.size();j++)
        {
            char z = k[j]; // let's supose z= 'f'
            int h = int(z);  // h=102
            h = h-97;  // h=5
            if(a[h]==0)
                count++;
            else
                count=count;
        }
        if(count>0)
            cout<<"No"<<endl;
        else
            cout<<"Yes"<<endl;
        
    }
}


================================================
FILE: Lecture - 20.cpp
================================================
#include <iostream>
#include <sstream>
using namespace std;
int main()
{
    string s;
    //cin>>s;
    getline(cin,s);
    cout<<s<<endl;
    cout<<s[0]<<endl;
    cout<<s[1]<<endl;
    cout<<s[2]<<endl;
    cout<<s[3]<<endl;
    cout<<s[4]<<endl;
    
    // -- we want to extrat the words --
    stringstream str(s);
    string word;   // it stores the words present in the string s
    while(str>>word)
    {
        cout<<word<<endl;
    }
}


================================================
FILE: Lecture - 21.cpp
================================================
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
    // problem 1.
    /*int a[10]={0};
    cout<<a[5]<<endl;
    
    int b[10]={21};  // method wrong ... and luckily valid for only 0 (zero )
    cout<<b[5]<<endl;  */
    
    // problem 2.
   /* int n ; cin>>n;
    int a[n]={0};
    cout<<a[5]<<endl; */
    
    // solution of these problem
    // memset ()
    int n;
    cout<<"Input the size of array"<<endl;
    cin>>n;
    int a[n]; // block name --- a
    memset(a,0 ,sizeof(a));  // value --> 0 & -1
    cout<<a[4]<<endl;
    
    int val[9];
    memset(val, -1 , sizeof(val));
    for(int i=0;i<9;i++)
    {
        cout<<val[i]<<" ";
    }
    cout<<endl;
    
}


================================================
FILE: Lecture - 22.cpp
================================================
// **--- program of print prime numbers ---**//

#include <iostream>
using namespace std;
int main()
{
    int n;
    cout<<"Enter value of n upto which you want to print prime number : "<<endl;
    cin>>n;
    for(int i=2;i<=n;i++)   /// 10
    {
        int x = i;  // 10
        int count=0;
        for(int j=1;j<=x;j++)  // j=1 to j=10
        {
            if(x%j==0) // 10%2==0
                count++;
        }
        if(count==2)
            cout<<x<<endl;
    }
}


================================================
FILE: Lecture - 24.cpp
================================================
//
//  main.cpp
//  Lecture - 24
//
//  Created by Prince  Kumar on 28/03/19.
//  Copyright © 2019 Prince  Kumar. All rights reserved.
//  seive of eratosthenes -- //

#include <iostream>
#include <cstring>
using namespace std;

void seive( int n)
{
    // create boolean array
    bool prime[n+1];
    memset(prime, true ,sizeof(prime));
    
    for(int p=2;p*p<=n;p++)
    {
        //  if prime[p] --> false  --> it is not prime
        if(prime[p]==true)
        {
            for(int i=p*p;i<=n;i=i+p)
            {
                prime[i]=false;
            }
        }
    }
    
    // print prime numbers
    for(int j=2;j<=n;j++)
    {
        if(prime[j]==true)
            cout<<j<<endl;
    }
}
int main()
{
    cout <<"Enter number upto which you want to print prime numbers "<<endl;
    int n ; cin>>n;
    seive(n);
}


================================================
FILE: Lecture - 25.cpp
================================================
//
//  main.cpp
//  hbhbhbs
//
//  Created by Prince  Kumar on 29/03/19.
//  Copyright © 2019 Prince  Kumar. All rights reserved.
//
// ** --- Euclidean Algorithm -- for finding GCD of 2 number **//

#include <iostream>
using namespace std;
int gcd(int a, int b)
{
    if(a==0)
        return b;
    else
        return gcd(b%a ,a);
    
}
int main()
{
    int a,b;
    cout<<"Enter two numbers "<<endl;
    cin>>a>>b;
    int result = gcd(a,b);
    cout<<result<<endl;
}


================================================
FILE: Lecture - 26.cpp
================================================
//
//  main.cpp
//  hsgts
//
//  Created by Prince  Kumar on 29/03/19.
//  Copyright © 2019 Prince  Kumar. All rights reserved.
//   Chef and his daily routine Problem Code: CHEFROUT

#include <iostream>
using namespace std;
int main()
{
    int T; cin>>T;
    while(T--)
    {
        string s; cin>>s;
        int count=0;
        for(int i=0;i<s.size()-1;i++)
        {
            if(s[i]=='C')
            {
                if(s[i+1]=='E' ||s[i+1]=='S' || s[i+1]=='C')
                    count++;
            }
            else if(s[i]=='E')
            {
                if(s[i+1]=='S' || s[i+1]=='E')
                    count++;
            }
            else if(s[i]=='S')
            {
                if(s[i+1]=='S')
                    count++;
            }
        }
        if(count==s.size()-1)
            cout<<"yes"<<endl;
        else
            cout<<"no"<<endl;
    }
}


================================================
FILE: Lecture - 27.cpp
================================================
//
//  main.cpp
//  lecture 27
//
//  Created by Prince  Kumar on 31/03/19.
//  Copyright © 2019 Prince  Kumar. All rights reserved.
//  code of codechef problem - Two vs Ten

#include <iostream>
using namespace std;
int main()
{
    int T; cin>>T;
    while(T--)
    {
        int x; cin>>x;
        if(x%10==0)
            cout<<"0"<<endl;
        else if(x%5==0)
            cout<<"1"<<endl;  // 5*2 =10
        else
            cout<<"-1"<<endl;
    }
}


================================================
FILE: Lecture - 31.cpp
================================================
//
//  main.cpp
//  lecture 31
//
//  Created by Prince  Kumar on 04/04/19.
//  Copyright © 2019 Prince  Kumar. All rights reserved.
//
// --- * Check the number is power of 2 * --- //
#include <iostream>
using namespace std;
int main()
{
    cout<<"Enter the number "<<endl;
    int x;
    cin>>x;
    int a = x & (x-1);
    if(a==0)
        cout<<"Number is the power of 2"<<endl;
    else
        cout<<"Number is NOT the power of 2"<<endl;
        
}


================================================
FILE: Lecture - 32.cpp
================================================
//
//  main.cpp
//  lecture 32
//
//  Created by Prince  Kumar on 05/04/19.
//  Copyright © 2019 Prince  Kumar. All rights reserved.
//  -- ** code of COUNT THE THE NUMBER OF ONE'S IN THE BINARY REPRESENTATION OF GIVEN NUMBER ** --- //

#include <iostream>
using namespace std;
int main()
{
    cout<<"Enter the number :"<<endl;
    int n; cin>>n;
    int x = n & (n-1);
    int count=1;
    while(x!=0)
    {
        count++;
        x = x & (x-1);
    }
    cout<<count<<endl;
    
    /*
     
     cout<<"Enter the number :"<<endl;
     int n; cin>>n;
     n = n & (n-1);
     int count=1;
     while(n!=0)
     {
     count++;
     n = n & (n-1);
     }
     
     
     */
}


================================================
FILE: Lecture - 33.cpp
================================================
//
//  main.cpp
//  lecture 33
//
//  Created by Prince  Kumar on 05/04/19.
//  Copyright © 2019 Prince  Kumar. All rights reserved.
//  -- **  code of  --> Check the ith bit is set in the binary form of given number ** --- //

#include <iostream>
using namespace std;
int main()
{
    cout<<"Enter the number : "<<endl;
    int n ; cin>>n;
    bool  a = n & ( 1<<3);
    if(a==true)
        cout<<"Yes, bit is set"<<endl;
    else
        cout<<"No,  bit is not set"<<endl;
        
}


================================================
FILE: Lecture - 34.cpp
================================================
//
//  main.cpp
//  Lecture 34
//
//  Created by Prince  Kumar on 17/04/19.
//  Copyright © 2019 Prince  Kumar. All rights reserved.
//   -- * Problems from codechef -> Train Partner -- ANKTRAIN * -//

#include <iostream>
using namespace std;
int main()
{
    int T; cin>>T;
    while(T--)
    {
        int n; // berth number
        cin>>n;
        if(n%8==0)
        {cout<<n-1<<"SL"<<endl;}
        else if(n%8==7)
        {cout<<n+1<<"SU"<<endl;}
        else if(n%8==1)
        {cout<<n+3<<"LB"<<endl;}
        else if(n%8==4)
        {cout<<n-3<<"LB"<<endl;}
        else if(n%8==2)
        {cout<<n+3<<"MB"<<endl;}
        else if(n%8==5)
        {cout<<n-3<<"MB"<<endl;}
        else if(n%8==3)
        {cout<<n+3<<"UB"<<endl;}
        else if(n%8==6)
        {cout<<n-3<<"UB"<<endl;}
    }
}


================================================
FILE: Leetcode/Add Digits.cpp
================================================
// https://leetcode.com/problems/add-digits/


class Solution {
public:
    
    int addDigitsHelper(int num){
        int sum = 0;
        while(num != 0){
            int digit = num % 10;
            sum += digit;
            num = num / 10;
        }
        return sum;
    }
    
    int addDigits(int num) {
        
        while(num > 9){
            num = addDigitsHelper(num);
        }
        
        return num;
    }
};


================================================
FILE: Leetcode/Add Two Numbers Leetcode Solutions in Linkedlist.cpp
================================================
/**
 * 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) {}
 
 *     https://leetcode.com/problems/add-two-numbers/
 
 * };
 */
class Solution {
public:
    ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) {
        ListNode *ans = new ListNode(0);
        ListNode *p = l1, *q=l2, *curr = ans;
        int carry=0;
        while(p!=NULL || q!=NULL){
            int x = (p!=NULL) ? p->val : 0;
            int y = (q!=NULL) ? q->val : 0;
            int sum = carry + x+ y;
            carry = sum/10;
            curr->next = new ListNode(sum%10);
            curr = curr->next;
            if(p!=NULL) p = p->next;
            if(q!=NULL) q = q->next;
        }
        if(carry>0){
            curr->next = new ListNode(carry);
        }
        return ans->next;
    }
};


================================================
FILE: Leetcode/Binary Search leetcode Solution.cpp
================================================
// https://leetcode.com/problems/binary-search/


class Solution {
public:
    int search(vector<int>& nums, int target) {
        
        int n = (int)nums.size();
        
        int low = 0;
        int high = n-1;
        
        while(low<=high){
            int mid = (low+high)/2;
            
            if(nums[mid] == target){
                return mid;
            }else if(nums[mid] < target ){
                low = mid+1;
            }else{
                high = mid-1;
            }
        }
        
        return -1;
        
    }
};


================================================
FILE: Leetcode/Boolean Matrix.cpp
================================================
// Boolean Matrix: https://practice.geeksforgeeks.org/problems/boolean-matrix-problem-1587115620/1#

void booleanMatrix(vector<vector<int> > &matrix)
    {
        // code here 
        int row = matrix.size();
        int col = matrix[0].size();
        
        bool arr_row[row]; fill(arr_row, arr_row+row, false);
        bool arr_col[col]; fill(arr_col, arr_col+col, false);
        
        for(int i=0;i<row;i++)
        {
            for(int j=0;j<col;j++){
                if(matrix[i][j] == 1){
                    arr_row[i] = true;
                    arr_col[j] = true;
                }
            }
        }
        
        for(int i=0;i<row;i++){
            if(arr_row[i]){
                for(int j=0;j<col;j++){
                    matrix[i][j]= 1;
                }
            }
        }
        
        for(int i=0;i<col;i++){
            if(arr_col[i]){
                for(int j=0;j<row;j++){
                    matrix[j][i] = 1;
                }
            }
        }
        
    }


================================================
FILE: Leetcode/Count the Number of Consistent Strings.cpp
================================================
// https://leetcode.com/problems/count-the-number-of-consistent-strings/

class Solution {
public:
    int countConsistentStrings(string allowed, vector<string>& words) {
        unordered_set<char> s;
        for(auto x: allowed)
            s.insert(x);
        
        int count = 0;
        for(auto word: words){
            
            bool status = true;
            for(int i=0; i<word.size(); i++){
                if(s.find(word[i]) == s.end()){
                    status = false;
                    break;
                }
            }
            if(status)
                count++;
        }
        
        return count;
    }
};


================================================
FILE: Leetcode/Graph/All Paths From Source to Target.cpp
================================================
// https://leetcode.com/problems/all-paths-from-source-to-target/

class Solution {
public:
    
    void dfs(vector<vector<int>>& graph, vector<vector<int>>& ans, vector<int>&path, int curr){
        
        path.push_back(curr);
        if(curr == graph.size()-1){
            ans.push_back(path);
        }
        else{
            for(auto x: graph[curr]){
                dfs(graph, ans, path, x);
            }
        }
        
        path.pop_back();
        
    }
    
    vector<vector<int>> allPathsSourceTarget(vector<vector<int>>& graph) {
        vector<vector<int>> ans;
        vector<int>path;
        
        dfs(graph, ans, path, 0);
        
        return ans;
    }
};


================================================
FILE: Leetcode/Graph/Course Schedule.cpp
================================================
// https://leetcode.com/problems/course-schedule/

class Solution {
public:
    
    bool DFSRec(int s, vector<bool>&visited, vector<bool>&currVisited, vector<int>adj[]){
        visited[s] = true;
        currVisited[s] = true;
        
        vector<int>data = adj[s];
        for(auto x: data){
            if(!visited[x]){
                if(DFSRec(x, visited, currVisited, adj)){
                    return true;
                }
            }
            else if(visited[x] && currVisited[x]){
                return true;
            }
        }
        
        currVisited[s] = false;
        return false;
    }
    
    bool canFinish(int numCourses, vector<vector<int>>& prerequisites) {
        
        int n = numCourses;
        vector<bool>visited(n, false), currVisited(n, false);
        
        vector<int>adj[n];
        for(auto x: prerequisites){
            vector<int>data = x;
            int a = data[0];
            int b = data[1];
            adj[a].push_back(b);
        }
        
        for(int i=0; i<n; i++){
            if(!visited[i]){
                if(DFSRec(i, visited, currVisited, adj)){
                    return false;
                }
            }
        }
        
        return true;
    }
};


================================================
FILE: Leetcode/Graph/Detect cycle in a directed graph.cpp
================================================
// https://practice.geeksforgeeks.org/problems/detect-cycle-in-a-directed-graph/1

class Solution {
  public:
    // Function to detect cycle in a directed graph.
    
    bool cycle(int s, vector<bool>&visited, vector<bool>&currVisited, vector<int> adj[]){
        visited[s] = true;
        currVisited[s] = true;
        
        for(auto x: adj[s]){
            if(!visited[x]){
                if(cycle(x, visited, currVisited, adj))
                    return true;
            }
            else if(visited[x] == true && currVisited[x] == true){
                return true;
            }
        }
        
        currVisited[s] = false;
        return false;
    }
    
    bool isCyclic(int V, vector<int> adj[]) {
        // code here
        vector<bool>visited(V, false), currVisited(V, false);
        for(int i=0; i<V; i++){
            if(!visited[i]){
                if(cycle(i, visited, currVisited, adj))
                    return true;
            }
        }
        
        return false;
    }
};



================================================
FILE: Leetcode/Graph/Find Eventual Safe States.cpp
================================================
// https://leetcode.com/problems/find-eventual-safe-states/

class Solution {
public:
    
    bool DFSRec(int s, vector<bool>&visited, vector<bool>&dfsVisited, vector<vector<int>>& graph, vector<bool> &present_cycle){
        visited[s] = true;
        dfsVisited[s] = true;
        
        vector<int>data = graph[s];
        for(auto x: data){
            if(!visited[x]){
                if(DFSRec(x, visited, dfsVisited, graph, present_cycle)){
                    return present_cycle[s] = true;
                }
            }
            else if(visited[x] && dfsVisited[x]){
                return present_cycle[s] = true;
            }
        }
        
        dfsVisited[s] = false;
        return false;
    }
    
    vector<int> eventualSafeNodes(vector<vector<int>>& graph) {
        vector<int> ans;
        
        int n = graph.size();
        vector<bool>visited(n, false), dfsVisited(n, false);
        vector<bool> present_cycle(n, false);
        
        for(int i=0; i<n; i++){
            if(!visited[i]){
                DFSRec(i, visited, dfsVisited,graph, present_cycle);
            }
        }
        
        for(int i=0; i<n; i++){
            if(!present_cycle[i]){
                ans.push_back(i);
            }
        }
        
        return ans;
    }
};


================================================
FILE: Leetcode/Graph/Find if Path Exists in Graph.cpp
================================================
// https://leetcode.com/problems/find-if-path-exists-in-graph/

class Solution {
public:
    bool validPath(int n, vector<vector<int>>& edges, int start, int end) {
        
        unordered_map<int, vector<int>> umap;
        for(auto x: edges){
            vector<int>temp = x;
            
            int u = temp[0];
            int v = temp[1];
            
            umap[u].push_back(v);
            umap[v].push_back(u);
        }
        
        vector<bool>visited(n+1, false);
        
        queue<int>q;
        q.push(start);
        visited[start] = true;
        
        while(!q.empty()){
            
            int v = q.front();
            q.pop();
            
            vector<int>temp = umap[v];
            for(int i=0; i<temp.size(); i++){
                int vertex = temp[i];
                if(visited[vertex] == false){
                    q.push(vertex);
                    visited[vertex] = true;
                }

            }
            
            if(visited[end])
                return visited[end];
        }
        
        return visited[end];
        
        
        
        
        
    }
};


================================================
FILE: Leetcode/Graph/Find the Town Judge.cpp
================================================
// https://leetcode.com/problems/find-the-town-judge/

class Solution {
public:
    int findJudge(int n, vector<vector<int>>& trust) {
        
        vector<int>data(n+1, 0);
        for(auto x: trust)
        {
            data[x[0]]--;
            data[x[1]]++;
        }
        
        for(int i=1; i<=n; i++){
            int x = data[i];
            if(x == n-1)
                return i;
        }
        
        return -1;
    }
};


================================================
FILE: Leetcode/Graph/Flood Fill.cpp
================================================
// https://leetcode.com/problems/flood-fill/

class Solution {
public:
    
    bool isValid(vector<vector<int>>& image, int i, int j, int n, int m , int color){
        
        if(i>=0 && i<n && j>=0 && j<m && image[i][j] == color)
            return true;
        
        return false;
    }
        
    void floodFillRec(vector<vector<int>>& image, int i, int j, int n, int m , int color, int newColor){
        
        image[i][j] = newColor;
        
        if(isValid(image, i+1, j, n, m , color))
            floodFillRec(image, i+1, j, n, m , color, newColor);
        
        if(isValid(image, i-1, j, n, m , color))
            floodFillRec(image, i-1, j, n, m , color, newColor);
        
        if(isValid(image, i, j+1, n, m , color))
            floodFillRec(image, i, j+1, n, m , color, newColor);
        
        if(isValid(image, i, j-1, n, m , color))
            floodFillRec(image, i, j-1, n, m , color, newColor);
    }
    
    vector<vector<int>> floodFill(vector<vector<int>>& image, int sr, int sc, int newColor) {
        
        int n = image.size();
        int m = image[0].size();
        
        int color = image[sr][sc];
        
        if(color == newColor)
            return image;
        
        floodFillRec(image, sr, sc, n, m, color, newColor);
        
        return image;
    }
};


================================================
FILE: Leetcode/Graph/Keys and Rooms.cpp
================================================
// https://leetcode.com/problems/keys-and-rooms/

class Solution {
public:
    bool canVisitAllRooms(vector<vector<int>>& rooms) {
        
        int n = rooms.size();
        vector<bool>visited(n, false);
        
        queue<int>q;
        q.push(0);
        visited[0] = true;
        
        while(!q.empty()){
            int room = q.front();
            q.pop();
            
            for(auto key : rooms[room]){
                if(!visited[key]){
                    visited[key] = true;
                    q.push(key);
                }
            }
        }
        
        
        for(auto x: visited){
            if(!x)
                return x;
        }
        
        return true;
    }
};


================================================
FILE: Leetcode/Graph/Max Area of Island.cpp
================================================
// https://leetcode.com/problems/max-area-of-island/

class Solution {
public:
    
    bool isValid(int i, int j, int n, int m, vector<vector<int>>& grid){
        if(i>=0 && i<n && j>=0 && j<m && grid[i][j] == 1){
            return true;
        }
        return false;
    }
    
    void dfs(vector<vector<int>>& grid, int i, int j, int n, int m, int &area){
        area++;
        grid[i][j] = 0;
        
        if(isValid(i+1, j, n, m, grid)){
            dfs(grid, i+1, j, n, m, area);
        }
        if(isValid(i-1, j, n, m, grid)){
            dfs(grid, i-1, j, n, m, area);
        }
        if(isValid(i, j+1, n, m, grid)){
            dfs(grid, i, j+1, n, m, area);
        }
        if(isValid(i, j-1, n, m, grid)){
            dfs(grid, i, j-1, n, m, area);
        }
    }
    
    int maxAreaOfIsland(vector<vector<int>>& grid) {
        
        int n = grid.size();
        int m = grid[0].size();
        int ans = 0;
        
        for(int i=0; i<n;i++){
            for(int j=0; j<m; j++){
                if(grid[i][j] == 1){
                    int area = 0;
                    dfs(grid, i, j, n, m, area);
                    ans = max(ans, area);
                }
            }
        }
        
        return ans;
    }
};


================================================
FILE: Leetcode/Graph/Minimum Time to Collect All Apples in a Tree.cpp
================================================
// https://leetcode.com/problems/minimum-time-to-collect-all-apples-in-a-tree/

class Solution {
public:
    vector<bool>visited;
    int dfs(vector<vector<int>>&adj, int node, int mycost, vector<bool>& hasApple){
        if(visited[node]) return 0;
        visited[node]= true;

        int childCost = 0;
        for(auto x: adj[node]){
            childCost += dfs(adj, x, 2, hasApple);
        }
        if(childCost == 0 && !hasApple[node]) return 0;
        return childCost + mycost;
    }
    int minTime(int n, vector<vector<int>>& edges, vector<bool>& hasApple) {
        vector<vector<int>>adj(n, vector<int>(0, -1));
        for(auto x: edges){
            adj[x[0]].push_back(x[1]);
            adj[x[1]].push_back(x[0]);
        }
        for(int i=0; i<n; i++){visited.push_back(false);}
        int time = 0;
        time = dfs(adj, 0, 0, hasApple);
        return time;
    }
};


================================================
FILE: Leetcode/Graph/Number of Enclaves.cpp
================================================
// https://leetcode.com/problems/number-of-enclaves/

class Solution {
public:
    
    int count(vector<vector<int>>& grid){
        int n = grid.size();
        int m = grid[0].size();
        int ans = 0;
        
        for(int i=0; i<n; i++){
            for(int j=0; j<m; j++){
                if(grid[i][j] == 1)
                    ans++;
            }
        }
        
        return ans;
    }
    
    bool isValid(int i, int j, int n, int m, vector<vector<int>>& grid){
        if(i>=0 && i<n && j>=0 && j<m && grid[i][j] == 1 ){
            return true;
        }
        return false;
    }
    
    void dfs(int i, int j, int n, int m, vector<vector<int>>& grid){
        grid[i][j] = 0;
        
        int ax[4] = {1, -1, 0, 0};
        int ay[4] = {0, 0, 1, -1};
        
        for(int k=0; k<4; k++){
            int nx = i + ax[k];
            int ny = j + ay[k];
            
            if(isValid(nx,ny, n, m, grid)){
                dfs(nx, ny, n, m, grid);
            }
        }
    }
    
    int numEnclaves(vector<vector<int>>& grid) {
        int n = grid.size();
        int m = grid[0].size();
        
        
        // boundary travers
        for(int i=0; i<n; i++){
            
            int j = 0;
            if(grid[i][j] == 1){
                dfs(i, j, n, m, grid);
            }
            
            j = m-1;
            if(grid[i][j] == 1){
                dfs(i, j, n, m, grid);
            }
            
        }
        
        
        for(int j=0; j<m; j++){
            
            int i = 0;
            if(grid[i][j] == 1){
                dfs(i, j, n, m, grid);
            }
            
            i = n-1;
            if(grid[i][j] == 1){
                dfs(i, j, n, m, grid);
            }
            
        }
        
        return count(grid);
        
    }
};


================================================
FILE: Leetcode/Graph/Number of Islands.cpp
================================================
// https://leetcode.com/problems/number-of-islands/

class Solution {
public:
    
    
    bool isValid(int i, int j, int n , int m, vector<vector<char>>& grid){
        if(i>=0 && i<n && j>=0 && j<m && grid[i][j] == '1')
            return true;
        
        return false;
    }
    
    void numIslandsRec(int i, int j, int n , int m, vector<vector<char>>& grid){
        
        grid[i][j] = '0';
        
        if(isValid(i+1, j, n, m , grid))
            numIslandsRec(i+1, j, n, m, grid);
        
        if(isValid(i-1, j, n, m , grid))
            numIslandsRec(i-1, j, n, m, grid);
        
        if(isValid(i, j+1, n, m , grid))
            numIslandsRec(i, j+1, n, m, grid);
        
        if(isValid(i, j-1, n, m , grid))
            numIslandsRec(i, j-1, n, m, grid);
        
    }
    
    int numIslands(vector<vector<char>>& grid) {
        
        int n = grid.size();
        int m = grid[0].size();
        int ans = 0;
        
        for(int i=0; i<n; i++){
            for(int j=0; j<m; j++){
                if(grid[i][j] == '1'){
                    ans++;
                    numIslandsRec(i, j, n, m, grid);
                }
            }
        }
        
        return ans;
    }
};


================================================
FILE: Leetcode/Graph/Number of Provinces.cpp
================================================
// https://leetcode.com/problems/number-of-provinces/

class Solution {
public:
    
    void dfs(int s, int n, vector<vector<int>>& isConnected, vector<bool>&visited){
        visited[s] = true;
        // s = 1
        
        // 0 1 2 3 4  -- index
        // 1 2 3 4 5  -- city name
        // 1 1 0 1 0  -- connection
        
        vector<int>adj;
        for(int i=0; i<n; i++ ){
            int x =  isConnected[s][i];  // x = connection
            if(x == 1)
                adj.push_back(i);
        }
        
        for(auto x: adj){
            if(!visited[x]){
                dfs(x, n, isConnected, visited);
            }
        }
        
        
    }
    
    int findCircleNum(vector<vector<int>>& isConnected) {
        
        int n = isConnected.size();
        vector<bool>visited(n, false);
        int count = 0;
        
        for(int i=0; i<n; i++){
            if(!visited[i]){
                count++;
                dfs(i, n, isConnected, visited);
            }
        }
        
        return count;
    }
};


================================================
FILE: Leetcode/Graph/Number of closed Islands.cpp
================================================
// https://leetcode.com/problems/number-of-closed-islands/

class Solution {
public:
    
    
    bool isValid(int i, int j, int n, int m ,vector<vector<int>>& grid){
        if(i>=0 && i<n && j>=0 && j<m && grid[i][j] == 0){
            return true;
        }
        return false;
    }
    
    void dfs(int i, int j, int n, int m ,vector<vector<int>>& grid){
        grid[i][j] = 1;
        
        int ax[4] = {1, -1, 0, 0};
        int ay[4] = {0, 0, 1, -1};
        
        for(int k =0; k<4; k++){
            int nx = i + ax[k];
            int ny = j + ay[k];
            
            if(isValid(nx, ny, n, m, grid)){
                dfs(nx, ny, n, m, grid);
            }
        }
    }
    
    int closedIsland(vector<vector<int>>& grid) {
        int n = grid.size();
        int m = grid[0].size();
        
        // boundary DFS
        for(int i=0; i<n; i++){
            for(int j=0; j<m; j++){
                if(i*j == 0 || i == n-1 || j==m-1){
                    // cout<<i<<" "<<j<<endl;
                    if(grid[i][j] == 0){
                        dfs(i, j, n, m, grid);
                    }
                }
            }
        }
        
        // call DFS in whole grid
        int ans = 0;
        for(int i=0; i<n; i++){
            for(int j=0; j<m; j++){
                if(grid[i][j] == 0){
                    ans++;
                    dfs(i, j, n, m, grid);
                }
            }
        }
        
        return ans;
    }
    
};


================================================
FILE: Leetcode/Graph/Rotting Oranges.cpp
================================================
// https://leetcode.com/problems/rotting-oranges/

class Solution {
public:
    
    
    bool isValid(int i, int j, int n, int m, vector<vector<int>>& grid){
        if(i>=0 && i<n && j>=0 && j<m && grid[i][j] == 1){
            return true;
        }
        return false;
    }
    
    int orangesRotting(vector<vector<int>>& grid) {
        int n = grid.size();
        int m = grid[0].size();
        
        int fresh = 0, time = 0;
        queue<pair<int, int>>q;
        
        for(int i=0; i<n; i++){
            for(int j=0; j<m; j++){
                if(grid[i][j] == 2){
                    // push into queue
                    q.push({i, j});
                }
                else if(grid[i][j] == 1){
                    fresh++;
                }
            }
        }
        if(fresh == 0) return 0;
        
        // start BFS traversal
        while(!q.empty()){
            
            int size_q = q.size();
            int temp = 0;
            while(size_q != 0){
                
                pair<int, int>p = q.front();
                q.pop();
                
                int x1 = p.first;
                int y1 = p.second;
                
                int ax[4] = { 1, -1, 0, 0};
                int ay[4] = { 0, 0 , 1 , -1};
                
                for(int i=0; i<4; i++){
                    int x = ax[i] + x1;
                    int y = ay[i] + y1;
                    
                    if(isValid(x, y, n, m, grid)){
                        temp++;
                        grid[x][y] = 2;
                        q.push({x, y});
                    }
                }
                
                size_q--;
                
            }
            if(temp != 0) time++;
        }
        
        
        
        // we checked if any fresh oranges are still there
        for(int i=0; i<n; i++){
            for(int j=0; j<m; j++){
                if(grid[i][j] == 1){
                    time = 0;
                    break;
                }
            }
        }
        
        
        
        return (time == 0) ? -1 : time ;
        
    }
};


================================================
FILE: Leetcode/Graph/Steps by Knight.cpp
================================================
// https://practice.geeksforgeeks.org/problems/steps-by-knight5927/1

class Solution 
{
    public:
    //Function to find out minimum steps Knight needs to reach target position.
    
    bool isValid(int i, int j, int n, vector<vector<bool>>&visited){
        if(i>=0 && i<n && j>=0 && j<n && visited[i][j] == false){
            return true;
        }
        return false;
    }
    
	int minStepToReachTarget(vector<int>&KnightPos,vector<int>&TargetPos,int N)
	{
	    // Code here
	    int n = N;
	    int tx = TargetPos[0]-1, ty = TargetPos[1]-1;
	    int x1 = KnightPos[0]-1, y1 = KnightPos[1]-1;
	    
	    if(x1 == tx && y1 == ty) return 0;
	    
	    vector<vector<bool>>visited(n, vector<bool>(n, false));
	    
	    queue<pair<int, int>>q;
	    q.push({x1, y1});
	    visited[x1][y1] = true;
	    
	    int ans = 0;
	    while(!q.empty()){
	        
	        int size = q.size();
	        ans++;
	        while(size != 0){
	            pair<int,int>p = q.front();
	            q.pop();
	            
	            int xx = p.first;
	            int yy = p.second;
	            
	            int ax[8] = {1, 1, -1, -1, 2, -2, 2, -2};
	            int ay[8] = {2, -2, 2, -2, 1, 1, -1, -1};
	            
	            for(int i=0; i<8; i++){
	                int nx = xx + ax[i];
	                int ny = yy + ay[i];
	                
	                if(nx == tx && ny == ty) return ans;
	                
	                if(isValid(nx, ny, n, visited)){
	                    visited[nx][ny] = true;
	                    q.push({nx, ny});
	                }
	            }
	           
	            size--;
	        }
	    }
	    
	    
	    return ans;
	    
	    
	}
};


================================================
FILE: Leetcode/Graph/Surrounded Regions.cpp
================================================
// https://leetcode.com/problems/surrounded-regions/

class Solution {
public:
    
    void convert(vector<vector<char>>& board){
        int n = board.size();
        int m = board[0].size();
        
        for(int i=0; i<n; i++){
            for(int j=0; j<m; j++){
                if(board[i][j] == 'B'){
                    board[i][j] = 'O';
                }
                else if(board[i][j] == 'O'){
                    board[i][j] = 'X';
                }
            }
        }
    }
    
    bool isValid(int i , int j, int n, int m, vector<vector<char>>& board){
        if(i>=0 && i<n && j>=0 && j<m && board[i][j] == 'O'){
            return true;
        }
        return false;
    }
    
    void dfs(vector<vector<char>>& board, int i , int j, int n, int m){
        board[i][j] = 'B';
        
        if(isValid(i+1, j, n, m, board)){
            dfs(board, i+1, j, n, m);
        }
        if(isValid(i-1, j, n, m, board)){
            dfs(board, i-1, j, n, m);
        }
        if(isValid(i, j+1, n, m, board)){
            dfs(board, i, j+1, n, m);
        }
        if(isValid(i, j-1, n, m, board)){
            dfs(board, i, j-1, n, m);
        }
    }
    
    void solve(vector<vector<char>>& board) {
        int n = board.size();
        int m = board[0].size();
        
        for(int i=0; i<n; i++){
            
            // left -> top bottom
            int j =0;
            if(board[i][j] == 'O'){
                dfs(board, i, j, n, m);
            }
            
            j = m-1;
            // right -> top bootm 
            if(board[i][j] == 'O'){
                dfs(board, i, j, n, m);
            }
        }
        
        for(int j=0; j<m; j++){
            
            // top -> left right
            int i =0;
            if(board[i][j] == 'O'){
                dfs(board, i, j, n, m);
            }
            
            i = n-1;
            // bottom -> left right
            if(board[i][j] == 'O'){
                dfs(board, i, j, n, m);
            }
        }
        
        convert(board);
    }
};


================================================
FILE: Leetcode/Graph/Time Needed to Inform All Employees.cpp
================================================
// https://leetcode.com/problems/time-needed-to-inform-all-employees/


class Solution {
public:
    
    unordered_map<int, vector<int>>umap;
    int ans =0 , mx= 0;
    
    void dfs(int manager, vector<int>& informTime){
        mx = max(mx, ans);
        for(auto employee : umap[manager]){
            ans += informTime[manager];
            
            dfs(employee, informTime);
            
            ans -= informTime[manager];
        }
        
    }
    
    int numOfMinutes(int n, int headID, vector<int>& manager, vector<int>& informTime) {
        
        // Fill umap
        for(int i=0; i<n; i++){
            int val = manager[i];
            if(val != -1){
                umap[val].push_back(i);
            }
        }
        
        dfs(headID, informTime);
        return mx;
        
    }
};


================================================
FILE: Leetcode/Graph/Topological sort .cpp
================================================
// https://practice.geeksforgeeks.org/problems/topological-sort/1

class Solution
{
	public:
	//Function to return list containing vertices in Topological order. 
	vector<int> topoSort(int V, vector<int> adj[]) 
	{
	    // code here
	    vector<int> ans;
	    queue<int>q;
	    
	    vector<int> indegree(V, 0);
	    for(int i=0; i<V; i++){
	        vector<int> data = adj[i];
	        for(auto x: data){
	            indegree[x]++;
	        }
	    }
	    
	    for(int i=0; i<V; i++){
	        if(indegree[i] == 0)
	            q.push(i);
	    }
	    
	    while(! q.empty()){
	        int u = q.front();
	        q.pop();
	        ans.push_back(u);
	        
	        for(auto v: adj[u]){
	            indegree[v]--;
	            if(indegree[v] == 0)
	                q.push(v);
	        }
	    }
	    
	    return ans;
	}
};


================================================
FILE: Leetcode/Graph/Topological sort using dfs.cpp
================================================
// https://practice.geeksforgeeks.org/problems/topological-sort/1

#include <bits/stdc++.h>
using namespace std;

 // } Driver Code Ends
class Solution
{
	public:
	//Function to return list containing vertices in Topological order. 
	
	void DFSRec(int s, stack<int>&st, vector<bool>&visited, vector<int> adj[]){
	    visited[s] = true;
	    
	    vector<int>data = adj[s];
	    for(auto v: data){
	        if(!visited[v]){
	            DFSRec(v, st, visited, adj);
	        }
	    }
	    
	    st.push(s);
	}
	
	vector<int> topoSort(int V, vector<int> adj[]) 
	{
	    // code here
	    stack<int>st;
	    vector<bool>visited(V, false);
	    
	    for(int i=0; i<V; i++){
	        if(!visited[i]){
	            DFSRec(i, st, visited, adj);
	        }
	    }
	    
	    vector<int>ans;
	    while(!st.empty()){
	        int x = st.top();
	        st.pop();
	        ans.push_back(x);
	    }
	    
	    return ans;
	    
	}
};


================================================
FILE: Leetcode/Hashing/Check if two arrays are equal or not.cpp
================================================
// Question Link: https://practice.geeksforgeeks.org/problems/check-if-two-arrays-are-equal-or-not3847/1

class Solution{
    public:

    //Function to check if two arrays are equal or not.
    bool check(vector<ll> A, vector<ll> B, int n) {
        //code here
        unordered_map<ll,ll>umap;
        for(int i=0;i<n;i++)
            umap[A[i]]++;
        for(int i=0;i<n;i++){
            ll key = B[i];
            if(umap.find(key)!=umap.end()){
                auto itr = umap.find(key);
                
                if(itr->second>0)
                    itr->second--;
                else
                    return false;
                
            }else
                return false;
        }
        
        return true;
    }
};


================================================
FILE: Leetcode/Hashing/Custom Sort String.cpp
================================================
// https://leetcode.com/problems/custom-sort-string/

class Solution {
public:
    string customSortString(string order, string str) {
        map<char, int>mp;
        string ans = "";
        
        for(auto x: str)
            mp[x]++;
        for(auto x: order){
            if(mp.find(x)!=mp.end()){
                auto temp = mp.find(x);
                int count = temp->second;
                // c-> 5  || ccccc
                string s(count, x);
                ans+=s;
                mp.erase(x);
            }
        }
        
        for(auto x: mp){
            string s(x.second, x.first);
            ans+=s;
        }
        return ans;
    }
};


================================================
FILE: Leetcode/Hashing/First Repeating Element.cpp
================================================
// Question Link: https://practice.geeksforgeeks.org/problems/first-repeating-element4018/1

class Solution{
    public:
    //Function to return the position of the first repeating element.
    int firstRepeated(int arr[], int n) {
        //code here
        unordered_map<int,int> umap;
        for(int i=0;i<n;i++)
            umap[arr[i]]++;
        for(int i=0;i<n;i++){
            int key = arr[i];
            
            auto temp = umap.find(key); 
            int val= temp->second;
            if(val >1)
                return i+1;
        }
        
        return -1;
    }
};


================================================
FILE: Leetcode/Hashing/Group Anagrams.cpp
================================================
// https://leetcode.com/problems/group-anagrams/

class Solution {
public:
    vector<vector<string>> groupAnagrams(vector<string>& strs) {
        vector<vector<string>> ans;
        unordered_map<string, vector<string>>umap;
        
        for(auto x: strs){
            string temp = x;
            sort(x.begin(), x.end());
            umap[x].push_back(temp);
        }
      
        for(auto x : umap){
            ans.push_back(x.second);
        }
        return ans;
        
    }
};


================================================
FILE: Leetcode/Hashing/Intersection of two arrays.cpp
================================================
// Question Link: https://practice.geeksforgeeks.org/problems/intersection-of-two-arrays2404/1

int NumberofElementsInIntersection (int a[], int b[], int n, int m )
{
    // Your code goes here
    unordered_set<int>s;
    for(int i=0;i<n;i++)    
        s.insert(a[i]);
    
    int count=0;
    for(int i=0;i<m;i++){
        int key = b[i];
        if(s.find(key)!=s.end()){
            count++;
            s.erase(key);
        }
    }
    return count;
}


================================================
FILE: Leetcode/Hashing/Key Pair.cpp
================================================
// Problem Link: https://practice.geeksforgeeks.org/problems/key-pair5616/1

class Solution{
public:	
	// Function to check if array has 2 elements
	// whose sum is equal to the given value
	bool hasArrayTwoCandidates(int arr[], int n, int x) {
	    // code here
	    unordered_map<int,int> umap;
	    for(int i=0;i<n;i++)
	        umap[arr[i]]++;
	    for(auto itr = umap.begin(); itr!=umap.end(); itr++){
	        int key = itr->first;
	        int val = itr->second;
	        
	        int pair = x-key;
	        if(pair==key){
	            if(val>1)
	                return true;
	        }else{
	            if(umap.find(pair)!=umap.end())
	                return true;
	        }
	    }
	    
	    return false;
	}
};


================================================
FILE: Leetcode/Hashing/LFU Cache.cpp
================================================
/* https://leetcode.com/problems/lfu-cache/ */

class LFUCache {
public:
    int capacity, minFreq;
    unordered_map<int, pair<int, int>>keyVal;
    unordered_map<int, list<int>> freqList;
    unordered_map<int, list<int>::iterator > pos;

    void updateFreq(int key){
        // update the Frequency  
        // -- delete key from curr_freq 
        // -- increment freq 
        // -- insert key in new freq
        // -- update new pos of key
        // -- check for minFreq 
        int curr_freq = keyVal[key].second; 
        freqList[curr_freq].erase(pos[key]);

        keyVal[key].second++;
        curr_freq = keyVal[key].second;

        freqList[curr_freq].push_back(key);

        pos[key] = --freqList[curr_freq].end();

        if(freqList[minFreq].empty()){
            minFreq++;
        }
    }

    LFUCache(int capacity) {
        this->capacity = capacity;
        minFreq = 0;
    }
    int get(int key) {
        if(keyVal.find(key) == keyVal.end()){
            return -1;
        }
        updateFreq(key);
        return keyVal[key].first;
    }
    
    void put(int key, int value) {
        if(capacity == 0) return;
        if(keyVal.find(key) != keyVal.end()){
            // update Case
            keyVal[key].first = value;
            updateFreq(key);
            return;
        }
        if(keyVal.size() == capacity){
            // Find the LRU;
            int delKey = freqList[minFreq].front();
            keyVal.erase(delKey);
            pos.erase(delKey);
            freqList[minFreq].pop_front();
        }
        keyVal[key] = {value, 1};
        freqList[1].push_back(key);
        pos[key] = --freqList[1].end();
        minFreq = 1;
    }
};

/**
 * Your LFUCache object will be instantiated and called as such:
 * LFUCache* obj = new LFUCache(capacity);
 * int param_1 = obj->get(key);
 * obj->put(key,value);
 */


================================================
FILE: Leetcode/Hashing/Non-Repeating Element.cpp
================================================
// Question Link: https://practice.geeksforgeeks.org/problems/non-repeating-element3958/1


class Solution{
    public:
    int firstNonRepeating(int arr[], int n) 
    { 
        // Complete the function
        unordered_map<int, int> umap;
        for(int i=0;i<n;i++)
            umap[arr[i]]++;
        
        // int key = arr[i];
        // umap[key]++;
        
        for(int i=0;i<n;i++){
            int key = arr[i];
            auto temp = umap.find(key);
            if(temp->second ==1)
                return key;
        }
        
        return 0;
    } 
  
};


================================================
FILE: Leetcode/Hashing/Pairs with Positive Negative values.cpp
================================================
// https://practice.geeksforgeeks.org/problems/pairs-with-positive-negative-values3719/1


class Solution{
  public:
    vector<int> PosNegPair(int a[], int n) {
        vector<int>v, ans;
        map<int,int>mp;
        
        for(int i=0;i<n;i++){
            if(a[i]<0)
                v.push_back(a[i]);
            else
                mp[a[i]]++;
        }
        
        sort(v.begin(), v.end());
        
        for(int i=(int)v.size()-1; i>=0 ; i--){
            int data = abs(v[i]);
            if(mp[data]>0){
                ans.push_back(v[i]);
                ans.push_back(data);
                mp[data]-=1;
            }
        }
        return ans;
    }
};


================================================
FILE: Leetcode/Hashing/Relative Sort Array.cpp
================================================
// https://leetcode.com/problems/relative-sort-array/

class Solution {
public:
    vector<int> relativeSortArray(vector<int>& arr1, vector<int>& arr2) {
        vector<int> ans;
        
        map<int, int>mp;
        for(auto x: arr1)
            mp[x]++;
        for(auto temp :  arr2){
            if(mp.find(temp)!=mp.end()){
                auto x  = mp.find(temp);
                int count = x->second;  // 5->2
                vector<int>v(count, temp); // v = 5 5 
                ans.insert(ans.end(), v.begin(), v.end());
                mp.erase(temp);
            }
        }
        
        for(auto x : mp){
            int ele = x.first;
            int count = x.second;
            vector<int>v(count, ele);
            ans.insert(ans.end(), v.begin(), v.end());
        }
        
        return ans;
    }
};


================================================
FILE: Leetcode/Hashing/Sort Array by Increasing Frequency.cpp
================================================
// https://leetcode.com/problems/sort-array-by-increasing-frequency/

class Solution {
public:
    vector<int> frequencySort(vector<int>& nums) {
        unordered_map<int, int>umap;
        for(auto x: nums){
            umap[x]++;
        }
        
        sort(nums.begin(), nums.end() , [&](int a , int b) 
             { return  umap[a] != umap[b] ? umap[a] < umap[b] :  a > b ; } );
        
        return nums;
    }
};


================================================
FILE: Leetcode/Hashing/Subarray with 0 sum.cpp
================================================
// Link: https://practice.geeksforgeeks.org/problems/subarray-with-0-sum-1587115621/1

class Solution{
    public:
    //Complete this function
    //Function to check whether there is a subarray present with 0-sum or not.
    bool subArrayExists(int arr[], int n)
    {
        //Your code here
        unordered_set<int>s;
        int pre_sum=0;
        for(int i=0;i<n;i++){
            pre_sum += arr[i];
            
            if(pre_sum == 0)
                return true;
            if(s.find(pre_sum)!=s.end())
                return true;
            
            s.insert(pre_sum);
        }
        return false;
    }
};


================================================
FILE: Leetcode/Hashing/Winner of an election.cpp
================================================
//  https://practice.geeksforgeeks.org/problems/winner-of-an-election-where-votes-are-represented-as-candidate-names-1587115621/1

class Solution{
  public:
  
    //Function to return the name of candidate that received maximum votes.
    vector<string> winner(string arr[],int n)
    {
        // Your code here
        // Return the string containing the name and an integer
        // representing the number of votes the winning candidate got
        
        unordered_map<string , int>umap;
        for(int i=0;i<n;i++){
            umap[arr[i]]++;
        }
        
        string name = "";
        int max_vote = 0;
        
        for(auto itr = umap.begin(); itr!=umap.end(); itr++){
            string key = itr->first;
            int val = itr->second;
            
            if(val>max_vote){
                max_vote = val;
                name = key;
            }
            else if(val == max_vote){
                if(key<name)
                    name = key;
            }
        }
        
        vector<string> ans;
        ans.push_back(name);
        string temp = to_string(max_vote);
        ans.push_back(temp);
        
        return ans;
    }  
};


================================================
FILE: Leetcode/Hashing/unordered_map.cpp
================================================
#include<bits/stdc++.h>
#include<unordered_map>

using namespace std;
int main(){
    unordered_map<string,int> umap;
    umap["prince"] = 44;
    umap["gfg"] = 56;
    umap["helloworld"] = 90;

    for(auto x : umap)
        cout<<x.first<<" "<<x.second<<endl;

    

    string key = "prince";
    
    if(umap.find(key) != umap.end())
        cout<<"key found"<<endl;
    else 
        cout<<"key not found"<<endl;

    if(umap.find(key) != umap.end()){
        auto temp = umap.find(key);
        cout<<"key is : "<<temp->first<<endl;
        cout<<"value is : "<<temp->second<<endl;
    }

    umap.insert(make_pair("mobile", 17000));

    key = "helloworld";
    umap.erase(key);

    for(auto itr = umap.begin() ; itr!=umap.end() ; itr++)
        cout<<itr->first<<" "<<itr->second<<endl;

    cout<<umap.size()<<endl;


    int arr[] = {7, 1, 0, 3, 5, 0, 1, 3, 2, 5, 7, 3, 8, 9, 9};
    unordered_map<int,int> umaped;

    for(int i=0;i<15;i++){
        int key = arr[i];
        umaped[key]++;
    }


    for(auto itr = umaped.begin() ; itr!=umaped.end() ; itr++)
        cout<<itr->first<<" "<<itr->second<<endl;
}


================================================
FILE: Leetcode/Hashing/unordered_set.cpp
================================================
#include<bits/stdc++.h>
#include<unordered_set>

using namespace std;
int main(){

    unordered_set<int> s;
    s.insert(10);
    s.insert(5);
    s.insert(15);
    s.insert(20);
    
    for(auto it = s.begin() ; it!=s.end() ;it++)
        cout<<(*it)<<endl;
    
    cout<<"number of element : "<<s.size()<<endl;

    s.clear();
    cout<<"number of element : "<<s.size()<<endl;


    int key = 20;

    if(s.find(key) == s.end()){
        cout<<"key not found"<<endl;
    }else{
        
        auto temp = s.find(key);
        s.erase(temp);

    }

    int deleted_key = 25;
    s.erase(deleted_key);

    for(auto it = s.begin() ; it!=s.end() ;it++)
        cout<<(*it)<<endl;

    cout<<"number of element : "<<s.size()<<endl;


    if(s.find(key)!=s.end())
        cout<<"key found"<<endl;


    if(s.count(5))
        cout<<"key found"<<endl;
    else
        cout<<"not found"<<endl;
}


================================================
FILE: Leetcode/Interchanging the rows of a Matrix.cpp
================================================
// problems: https://practice.geeksforgeeks.org/problems/reversing-the-rows-of-a-matrix-1587115621/1/?track=DSASP-Matrix&batchId=154


void interchangeRows(vector<vector<int> > &matrix)
    {
        // code here
        int row = matrix.size();
        int col = matrix[0].size();
        
        for(int i=0;i<(row/2);i++){
            for(int j=0;j<col;j++)
                swap(matrix[i][j], matrix[row-1-i][j]);
        }
    }


================================================
FILE: Leetcode/Majority Element Geeksforgeeks leetcode Moore's Voting Algorithm.cpp
================================================
// https://practice.geeksforgeeks.org/problems/majority-element/0


#include<bits/stdc++.h>
using namespace std;

// Function to find majority element in the array
int majorityElement(int arr[], int n)
{
    int count=1; int res=0;
    for(int i=1; i<n; i++){
        if(arr[res] == arr[i])
            count++;
        else
            count--;
            
        if(count==0){
            count=1;
            res=i;
        }
    }
    
    //2nd   res 
    count=0;
    for(int i=0;i<n;i++){
        if(arr[res]==arr[i])
            count++;
    }
    
    if(count <= (n/2))
        return -1;
    else
        return arr[res];
}

int main(){

    int t;
    cin >> t;

    while(t--){
        int n;
        cin >> n;
        int arr[n];
        
        for(int i = 0;i<n;i++){
            cin >> arr[i];
        }
        
        cout << majorityElement(arr, n) << endl;
    }

    return 0;
}


================================================
FILE: Leetcode/Median of Two sorted arrays.cpp
================================================
// https://practice.geeksforgeeks.org/problems/median-of-two-sorted-arrays1618/1/?track=DSASP-Searching&batchId=154


// arr : given array with size n 
// brr : given array with size m
int findMedian(int arr[], int n, int brr[], int m){
    // code here
    int begin1 = 0 ; int end1 = n;
    while(begin1<=end1){
        int i1 = (begin1+end1)/2;
        int i2 = (n+m+1)/2 - i1;
        
        int min1 = (i1==n) ? INT_MAX : arr[i1];
        int max1 = (i1==0) ? INT_MIN : arr[i1-1];
        
        int min2 = (i2==m) ? INT_MAX : brr[i2];
        int max2 = (i2==0) ? INT_MIN : brr[i2-1];
        
        if((max1<=min2) && (max2<=min1) ){
            if((n+m)%2==0){
                return ((double) (max(max1,max2) + min(min1, min2)) / 2) ;
            }else{
                return ((double) max(max1, max2));
            }
        }
        else if(max1>min2){
            end1 = i1-1;
        }else{
            begin1 = i1+1;
        }
    }
}


================================================
FILE: Leetcode/Middle of the Linked List Leetcode.cpp
================================================
// https://leetcode.com/problems/middle-of-the-linked-list/


/**
 * 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:
    
    int size(ListNode* head){
        int n=0;
        while(head != NULL){
            n++;
            head = head->next;
        }
        return n;
    }
    
    ListNode* middleNode(ListNode* head) {
        int n  = size(head);
        
        n = (n/2) + 1;
        
        int i=0;
        while(head != NULL){
            i++;
            if(i==n)
                return head;
            head = head->next;
        }
        
        return head;
    }
};


================================================
FILE: Leetcode/Middle of the Linked List.cpp
================================================
/**
 * 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* middleNode(ListNode* head) {
        
        vector<ListNode*> v = {head};
        while(v.back()->next!=NULL){
            v.push_back(v.back()->next);
        }
        return v[(int)v.size()/2];
        
        
        
//       int count=0;
//         ListNode* temp = head;
//         while(temp!=NULL){
//             count++;
//             temp = temp->next;
//         }
        
//         count/=2;
//         int i=0;
//         ListNode* ans;
        
//         while(i<=count){
//             ans = head;
//             head = head->next;
//             i++;
//         }
        
//         return ans;
    }
};


================================================
FILE: Leetcode/Move Zeroes.cpp
================================================
// https://leetcode.com/problems/move-zeroes/

class Solution {
public:
    void moveZeroes(vector<int>& nums) {
        
        int n = nums.size();
        int j=0;
        
        for(int i=0; i<n; i++){
            if(nums[i]!=0){
                nums[j] = nums[i];
                j++;
            }
        }
        
        for(; j<n; j++){
            nums[j] = 0;
        }
    }
};


================================================
FILE: Leetcode/Multiply two matrices.cpp
================================================
// Problem link: https://practice.geeksforgeeks.org/problems/multiply-the-matrices-1587115620/1

vector<vector<int> > multiplyMatrix( const vector<vector<int> >& A, const vector<vector<int> >& B)
    {
        // code here
        int n1,m1, n2, m2;
        n1 = A.size();
        n2 = B.size();
        
        //col
        m1 = A[0].size();
        m2 = B[0].size();
        vector<vector<int>> ans;

        if(m1 == n2){
            for(int i=0;i<n1;i++){
                vector<int> temp;
                
                for(int j=0; j<m2;j++){
                    int sum=0;
                    for(int k=0;k<m1;k++){
                        sum = sum + (A[i][k] * B[k][j]);
                    }
                    temp.push_back(sum);
                }
                ans.push_back(temp);
            }
        }
        
        return ans;
    }


================================================
FILE: Leetcode/Naive Pattern Search.cpp
================================================
GFG : https://practice.geeksforgeeks.org/problems/naive-pattern-search-1587115620/1/
Leetcode : https://leetcode.com/problems/implement-strstr/


bool search(string pat, string txt) 
{ 
	
	// Your code here
	int m = txt.size();
	int n = pat.size();
	
	for(int i=0; i<=(m-n) ;i++){
	    
	    bool isBool = true;
	    for(int j=0; j<n ;j++){
	        if(pat[j]!=txt[j+i]){
	            isBool = false;
	            break;
	        }
	    }
	    
	    if(isBool){
	        return true;
	    }
	    
	}
	
	return false;
}


================================================
FILE: Leetcode/Next Greater Element.cpp
================================================
// https://practice.geeksforgeeks.org/problems/next-larger-element-1587115620/1


{
    public:
    //Function to find the next greater element for each element of the array.
    vector<long long> nextLargerElement(vector<long long> arr, int n){
        // Your code here
        stack<long long> st;
        vector<long long>ans;
        
        ans.push_back(-1);
        st.push(arr[n-1]);
        
        for(long long i= n-2; i>=0; i--){
            
            while(!st.empty() && st.top() <= arr[i])
                st.pop();
                
            long long next = (st.empty()) ? -1 : st.top();
            ans.push_back(next);
            st.push(arr[i]);
        }
        
        reverse(ans.begin(), ans.end());
        return ans;
    }
};


================================================
FILE: Leetcode/Non Repeating Character.cpp
================================================
// Complete this function
char nonrepeatingCharacter(string s)
{
   int chars = 256;
   int n = s.size();
   
   int arr[chars];
   fill(arr, arr+chars, 0);
   
   for(int i=0;i<n;i++){
       arr[s[i]]++;
   }
   
   // 1 1 2 1
   
   for(int i=0;i<n;i++){
       if(arr[s[i]] == 1)
            return (char)s[i];
   }
   
   return '$';
   
}


================================================
FILE: Leetcode/Peak element.cpp
================================================
// https://practice.geeksforgeeks.org/problems/peak-element/1

int peakElement(int arr[], int n)
{
   // Your code here
   int low = 0;
   int high = n-1;
   
   while(low<=high){
       int mid = (low+high)/2;
       
       if(
          (mid==0 || arr[mid]>=arr[mid-1]) &&
          (mid == n-1 || arr[mid]>=arr[mid+1])
         ){
             return mid;
         }
        else if(arr[mid]<=arr[mid+1]){
            low = mid+1;
        }else{
            high = mid-1;
        }
   }
   
   return -1;
}


================================================
FILE: Leetcode/Rearrange Array Alternately Geeksforgeeks.cpp
================================================
// https://practice.geeksforgeeks.org/problems/-rearrange-array-alternately/0

#include <iostream>
using namespace std;

void rearrange(long long int arr[], int n){
    int max_index = n-1;
    int min_index = 0;
    int max = arr[n-1]+1;
    
    for(int i=0;i<n;i++){
        if(i%2==0){
            arr[i] = ( arr[max_index]%max ) * max + arr[i];
            max_index--;
        }else{
            arr[i] = ( arr[min_index]%max ) * max + arr[i];
            min_index++;
        }
    }
    
    for(int i=0;i<n;i++){
        arr[i]/=max; // arr[i] = arr[i]/max;
    }
}

int main() 
{
    int t;
    
    //testcases
    cin >> t;
    
    while(t--){
        
        //size of array
        int n;
        cin >> n;
        
        long long int arr[n];
        
        //adding elements to the array
        for(int i = 0;i<n;i++){
            cin >> arr[i];
        }
        
        //calling rearrange() function
        rearrange(arr, n);
        
        //printing the elements
        for (int i = 0; i < n; i++) 
		    cout << arr[i] << " ";
		
		cout << endl;
    }
	return 0; 
}


================================================
FILE: Leetcode/Recursion/0-1 Knapsack Problem Top down.cpp
================================================
// https://practice.geeksforgeeks.org/problems/0-1-knapsack-problem0945/1

class Solution
{
    public:
    //Function to return max value that can be put in knapsack of capacity W.
    int knapSack(int W, int wt[], int val[], int n) 
    {
       // Your code here
       vector<vector<int>>dp(n+1, vector<int>(W+1, -1));
       for(int i=0; i<=n; i++){
           dp[i][0] = 0;
       }
       for(int i=0; i<=W; i++){
           dp[0][i] = 0;
       }
       
       for(int i=1; i<=n; i++){
           for(int j=1; j<=W; j++){
               if(wt[i-1] <= j){
                   dp[i][j] = max( val[i-1] + dp[i-1][j-wt[i-1]], 
                                   dp[i-1][j]    );
               }else{
                   dp[i][j] = dp[i-1][j];
               }
           }
       }
       
       return dp[n][W];
    }
};


================================================
FILE: Leetcode/Recursion/Best Time to Buy and Sell Stock.cpp
================================================
// https://leetcode.com/problems/best-time-to-buy-and-sell-stock/

class Solution {
public:
    int maxProfit(vector<int>& prices) {
        int i=1, profit = 0, min_price = prices[0], n = prices.size();
        while(i<n){
            if(prices[i] < min_price){
                min_price = prices[i];
            }else{
                profit = max(profit, prices[i]-min_price);
            }
            i++;
        }
        return profit;
    }
};


================================================
FILE: Leetcode/Recursion/Climbing Stairs.cpp
================================================
// https://leetcode.com/problems/climbing-stairs/

vector<int>dp(46, -1);
class Solution {
public:
    int climbStairs(int n) {
        if(dp[n] != -1) return dp[n];
        if(n<=2){
            return dp[n] = n;
        }
        return dp[n] = climbStairs(n-1) + climbStairs(n-2);
    }
};


================================================
FILE: Leetcode/Recursion/Decode Ways.cpp
================================================
// https://leetcode.com/problems/decode-ways/

vector<int>dp(101, -1);
class Solution {
public:
    int n = 0;
    int numDecodingsHelper(string s, int pos){
        if(pos == n) return 1;
        if(s[pos] == '0') return 0;
        
        if(dp[pos] != -1) return dp[pos];

        int count = numDecodingsHelper(s , pos+1);
        if(pos < n-1 && s.substr(pos, 2) < "27"){
            count += numDecodingsHelper(s, pos+2);
        }
        return dp[pos] = count;
    }
    int numDecodings(string s) {
        n = s.size();
        fill(dp.begin(), dp.end(), -1);
        return numDecodingsHelper(s, 0);
    }
};


================================================
FILE: Leetcode/Recursion/Delete middle element of a stack.cpp
================================================
// https://practice.geeksforgeeks.org/problems/delete-middle-element-of-a-stack/1

class Solution
{
    public:
    //Function to delete middle element of a stack.
    
    void deleteMidHelper(stack<int>&st, int count, int &pos){
        if(st.empty()) return;
        if(count == pos) {st.pop(); return;}
        
        int top = st.top(); st.pop();
        deleteMidHelper(st, count+1, pos);
        
        st.push(top);
    }
    
    void deleteMid(stack<int>&s, int sizeOfStack)
    {
        // code here.. 
        int pos = ceil((sizeOfStack+1)/2.0);
        deleteMidHelper(s, 1, pos);
        
    }
};


================================================
FILE: Leetcode/Recursion/Divisor Game.cpp
================================================
// https://leetcode.com/problems/divisor-game/

class Solution {
public:
    bool divisorGame(int n) {
        // if(n<=1) return false;
        // for(int x=1; x<n; x++){
        //     if(n%x==0){
        //         return !divisorGame(n-x);
        //     }
        // }
        // return false;

        if(n%2==0)return true;
        return false;
    }
};


================================================
FILE: Leetcode/Recursion/Factorial.cpp
================================================
// https://practice.geeksforgeeks.org/problems/factorial5739/1

class Solution{
public:
    long long int factorial(int N){
        //code here
        if(N<=1) return 1;
        return N * factorial(N-1);
    }
};


================================================
FILE: Leetcode/Recursion/Fibonacci Number.cpp
================================================
// https://leetcode.com/problems/fibonacci-number/

class Solution {
public:
    int fib(int n) {
        if(n<=1) return n;
        return fib(n-1)+fib(n-2);
    }
};


================================================
FILE: Leetcode/Recursion/House Robber.cpp
================================================
// https://leetcode.com/problems/house-robber/

vector<int>dp(101, -1);
class Solution {
public:
    int fun(vector<int>& nums, int n){
        if(n<=0) return 0;
        if(dp[n] != -1) return dp[n];
        return dp[n] = max(
            fun(nums, n-1),
            nums[n-1] + fun(nums, n-2)
        );
    }
    int rob(vector<int>& nums) {
        int n = nums.size();
        fill(dp.begin(), dp.end(), -1);
        return fun(nums, n);
    }
};


================================================
FILE: Leetcode/Recursion/Largest Element in Array.cpp
================================================
// https://practice.geeksforgeeks.org/problems/largest-element-in-array4009/1

class Solution
{
public:
    int largest(vector<int> &arr, int n)
    {
        if(n==1) return arr[0];
        return max( largest(arr, n-1), arr[n-1] );
    }
};


================================================
FILE: Leetcode/Recursion/Min Cost Climbing Stairs.cpp
================================================
// https://leetcode.com/problems/min-cost-climbing-stairs/

vector<int>dp(1001, -1);
class Solution {
public:

    int minCost(vector<int>& cost, int n){
        if(dp[n] != -1) return dp[n];
        if(n<=1) return dp[n] = 0;
        if(n==2) return dp[n] =  min(cost[0], cost[1]);
        return dp[n] =  min( minCost(cost, n-1) + cost[n-1],
                    minCost(cost, n-2) + cost[n-2] );
    }
    int minCostClimbingStairs(vector<int>& cost) {
        int n = cost.size();
        fill(dp.begin(), dp.end(), -1);
        return minCost(cost, n);
    }
};


================================================
FILE: Leetcode/Recursion/Nth Fibonacci Number.cpp
================================================
// https://practice.geeksforgeeks.org/problems/nth-fibonacci-number1335/1

vector<long long int>dp(1001, -1);
class Solution {
  public:
    int mod = 1000000007;
    long long int nthFibonacci(long long int n){
        if(dp[n] != -1) return dp[n];
        // code here
        if(n<=1){
            return dp[n] = n;
        };
        return dp[n] = (nthFibonacci(n-1)%mod + nthFibonacci(n-2)%mod)%mod;
    }
};


================================================
FILE: Leetcode/Recursion/Partition Equal Subset Sum.cpp
================================================
// https://leetcode.com/problems/partition-equal-subset-sum/

/****************************** RECURSION *************************************************/
/****************************** TIME LIMIT EXCEEDED *************************************************/

class Solution {
public:

    bool subsetSum(vector<int>& nums, int n, int sum){
        if(n==0) return false;
        if(sum==0) return true;
        if(nums[n-1] <= sum){
            return subsetSum(nums, n-1, sum-nums[n-1]) || subsetSum(nums, n-1, sum);
        }else{
            return subsetSum(nums, n-1, sum);
        }
    }
    bool canPartition(vector<int>& nums) {
        int n = nums.size();
        int sum = 0;
        for(auto x: nums){
            sum += x;
        }
        if(sum%2 != 0) return false;
        
        sum = sum/2;
        return subsetSum(nums, n, sum);
    }
};




/****************************** MEMOIZATION *************************************************/
class Solution {
public:

    bool subsetSum(vector<int>& nums, int n, int sum, vector<vector<int>>&dp){
        if(dp[n][sum] != -1) return dp[n][sum];
        if(nums[n-1] <= sum){
            return dp[n][sum] = subsetSum(nums, n-1, sum-nums[n-1], dp) || subsetSum(nums, n-1, sum, dp);
        }else{
            return dp[n][sum] = subsetSum(nums, n-1, sum, dp);
        }
    }
    bool canPartition(vector<int>& nums) {
        int n = nums.size();
        int sum = 0;
        for(auto x: nums){
            sum += x;
        }
        if(sum%2 != 0) return false;
        
        sum = sum/2;
        vector<vector<int>>dp(n+1, vector<int>(sum+1, -1));
        for(int i=0; i<=sum; i++){
            dp[0][i] = false;
        }
        for(int i=0; i<=n; i++){
            dp[i][0] = true;
        }
        return subsetSum(nums, n, sum, dp);
    }
};




/****************************** TOP DOWN *************************************************/

class Solution {
public:
    bool canPartition(vector<int>& nums) {
        int sum = 0, n = nums.size();
        for(auto x: nums) sum += x;
        if(sum % 2 != 0) return false; 
        sum /= 2;
        vector<vector<bool>>t(n+1, vector<bool>(sum+1, false));
        for(int i=0; i<n+1; i++){t[i][0] = true;}
        for(int i=1; i<n+1; i++){
            for(int j=1; j<sum+1; j++){
                if(nums[i-1]<=j){
                    t[i][j] = ( t[i-1][j-nums[i-1]] || t[i-1][j] );
                }else{
                    t[i][j] = t[i-1][j];
                }
            }
        }
        return t[n][sum];
    }
};


================================================
FILE: Leetcode/Recursion/Perfect Squares.cpp
================================================
// https://leetcode.com/problems/perfect-squares/

vector<int>dp(10001, -1);
class Solution {
public:
    int solve(int n){
        if(n<=0) return 0;
        int ans = INT_MAX;
        if(dp[n] != -1) return dp[n];

        for(int i=1; i*i<=n; i++){
            int sqnum = i*i;
            int count = 1+ solve(n-sqnum);
            ans = min(ans, count);
        }
        return dp[n] = ans;
    }
    int numSquares(int n) {
        return solve(n);
    }
};


================================================
FILE: Leetcode/Recursion/Perfect Sum Problem.cpp
================================================
// https://practice.geeksforgeeks.org/problems/perfect-sum-problem5633/1


/****************************** RECURSION *************************************************/
/****************************** TIME LIMIT EXCEEDED *************************************************/

class Solution{

	public:
	int mod = 1e9+7;  // 1000000007
	int countSubset(int arr[], int n, int sum){
	    if(n==0 and sum > 0) return 0;
	    else if(n==1){
	        if(sum==0){
	            if(arr[0] == 0) return 2;
	            else return 1;
	        }else{
	            if(arr[0] == sum) return 1;
	            else return 0;
	        }
	    }
	    else if(n==0 and sum==0) return 1;
	    
	    if(arr[n-1] <= sum){
	        return countSubset(arr,n-1, sum-arr[n-1]) + countSubset(arr, n-1, sum);
	    }else
	        return countSubset(arr, n-1, sum);
	}
	int perfectSum(int arr[], int n, int sum)
	{
        // Your code goes here
        return countSubset(arr, n, sum);
        
	}
	  
};


/****************************** MEMOIZATION *************************************************/

class Solution{

	public:
	int mod = 1e9+7;  // 1000000007
	int countSubset(int arr[], int n, int sum, vector<vector<int>>&dp){
	    if(dp[n][sum] != -1) return dp[n][sum];
	    if(n==0 and sum > 0) return 0;
	    else if(n==1){
	        if(sum==0){
	            if(arr[0] == 0) return 2;
	            else return 1;
	        }else{
	            if(arr[0] == sum) return 1;
	            else return 0;
	        }
	    }
	    else if(n==0 and sum==0) return 1;
	    
	    int ans = countSubset(arr, n-1, sum, dp) % mod;
	    if(arr[n-1] <= sum){
	        ans+=countSubset(arr,n-1, sum-arr[n-1], dp);
	        ans %= mod;
	    }
	    return dp[n][sum] = ans;
	}
	int perfectSum(int arr[], int n, int sum)
	{
        // Your code goes here
        vector<vector<int>>dp(n+1, vector<int>(sum+1, -1));
        return countSubset(arr, n, sum, dp) % mod;
        
	}
	  
};


================================================
FILE: Leetcode/Recursion/Power Of Numbers.cpp
================================================
// https://practice.geeksforgeeks.org/problems/power-of-numbers-1587115620/1

class Solution{
    public:
    //You need to complete this fucntion
    
    long long power(int N,int R)
    {
        int MOD = 1e9+7;
       //Your code here
       if(N==0) return 0;
       if(R==0) return 1;
       if(R%2==0){
           long long ans = power(N, R/2);
           return ( ans%MOD * ans%MOD  )%MOD;
       }else{
           long long ans = power(N, (R-1)/2);
           return ( ans%MOD * ans%MOD * N%MOD)%MOD;
       }
    }

};


================================================
FILE: Leetcode/Recursion/Print 1 To N Without Loop.cpp
================================================
// https://practice.geeksforgeeks.org/problems/print-1-to-n-without-using-loops-1587115620/1

class Solution{
    public:
    //Complete this function
    void printNos(int N)
    {
        //Your code here
        if(N==0) return;
        printNos(N-1);
        cout<<N<<" ";
    }
};


================================================
FILE: Leetcode/Recursion/Reverse a String.cpp
================================================
// https://practice.geeksforgeeks.org/problems/reverse-a-string/1

string reverseWord(string str){
    
  //Your code here
  if(str.size() == 0 || str.size()== 1) return str;
  return reverseWord(str.substr(1)) + str[0];
}


================================================
FILE: Leetcode/Recursion/Subset Sum Problem.cpp
================================================
// https://practice.geeksforgeeks.org/problems/subset-sum-problem-1611555638/1

/****************************** RECURSION *************************************************/
/****************************** TIME LIMIT EXCEEDED *************************************************/

class Solution{   
public:
    bool subsetSum(vector<int>arr, int n, int sum){
        if(n==0) return false;
        if(sum==0) return true;
        if(arr[n-1] <= sum){
            return subsetSum(arr, n-1, sum-arr[n-1]) || subsetSum(arr, n-1, sum);
        }else{
            return subsetSum(arr, n-1, sum);
        }
    }
    bool isSubsetSum(vector<int>arr, int sum){
        // code here
        int n = arr.size();
        return subsetSum(arr, n, sum);
    }
};



/****************************** MEMOIZATION *************************************************/
class Solution{   
public:
    bool subsetSum(vector<int>arr, int n, int sum, vector<vector<int>>&dp){
        if(dp[n][sum] != -1) return dp[n][sum];
        if(arr[n-1] <= sum){
            return dp[n][sum] = subsetSum(arr, n-1, sum-arr[n-1], dp) || subsetSum(arr, n-1, sum, dp);
        }else{
            return dp[n][sum] = subsetSum(arr, n-1, sum, dp);
        }
    }
    bool isSubsetSum(vector<int>arr, int sum){
        // code here
        int n = arr.size();
        vector<vector<int>>dp(n+1, vector<int>(sum+1, -1));
        for(int i=0; i<=sum; i++){
            dp[0][i] = false;
        }
        for(int i=0; i<=n; i++){
            dp[i][0] = true;
        }
        return subsetSum(arr, n, sum, dp);
    }
};


================================================
FILE: Leetcode/Recursion/Sum of Array.cpp
================================================
// https://practice.geeksforgeeks.org/problems/sum-of-array2326/1

class Solution{
public:
	// function to return sum of elements
	// in an array of size n
	int sum(int arr[], int n) {
	    // code here
	    if(n == 0) return 0;
	    return arr[n-1] + sum(arr, n-1);
	}
};


================================================
FILE: Leetcode/Recursion/Target Sum.cpp
================================================
// https://leetcode.com/problems/target-sum/

class Solution {
public:

		int countSubset(vector<int>& nums, int n, int sum, vector<vector<int>>&dp){
	    if(dp[n][sum] != -1) return dp[n][sum];
	    if(n==0 and sum > 0) return 0;
	    else if(n==1){
	        if(sum==0){
	            if(nums[0] == 0) return 2;
	            else return 1;
	        }else{
	            if(nums[0] == sum) return 1;
	            else return 0;
	        }
	    }
	    else if(n==0 and sum==0) return 1;
	    
	    int ans = countSubset(nums, n-1, sum, dp);
	    if(nums[n-1] <= sum){
	        ans+=countSubset(nums,n-1, sum-nums[n-1], dp);
	    }
	    return dp[n][sum] = ans;
	}
    int findTargetSumWays(vector<int>& nums, int target) {
        int n = nums.size();
				int sum = 0;
				for(auto x: nums) {sum += x;}
				if(sum < abs(target) || (target + sum) % 2 !=0 ) return 0;
				
				sum = (sum+target)/2;
				vector<vector<int>>dp(n+1, vector<int>(sum+1, -1));
        return countSubset(nums, n, sum, dp);
    }
};


================================================
FILE: Leetcode/Recursion/Tower Of Hanoi.cpp
================================================
// https://practice.geeksforgeeks.org/problems/tower-of-hanoi-1587115621/1

class Solution{
    public:
    // You need to complete this function

    // avoid space at the starting of the string in "move disk....."
    long long count = 0;
    void TOHHelper(int N, int from, int to, int aux){
        if(N>0){
            TOHHelper(N-1, from, aux, to);
            cout << "move disk " << N << " from rod " << from << " to rod " << to << endl;
            count++;
            TOHHelper(N-1, aux, to, from);
        }
    } 
    long long toh(int N, int from, int to, int aux) {
        // Your code here
        TOHHelper(N, from, to , aux);
        return count;
    }

};


================================================
FILE: Leetcode/Reverse Linked List.cpp
================================================
// https://leetcode.com/problems/reverse-linked-list/

/**
 * 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* reverseList(ListNode* head) {
        ListNode* new_head = NULL;
         
        while( head != NULL){
             ListNode* temp = head;
             head = head->next;
             temp->next = new_head;
             new_head = temp;
        }
        
        return new_head;
    }
};


================================================
FILE: Leetcode/Rotate Array Leetcode.cpp
================================================
class Solution {
public:
    
    void reverse(vector<int> &num, int low, int high){
        while(low < high){
            swap(num[low], num[high]);
            low++;
            high--;
        }
    }
    void rotate(vector<int>& nums, int k) {
        
        int n = (int)nums.size();
        k = k%n;
        reverse(nums, 0, n-k-1);
        reverse(nums, n-k, n-1);
        reverse(nums, 0, n-1);
    }
};


================================================
FILE: Leetcode/Rotate List.cpp
================================================
// https://leetcode.com/problems/rotate-list/


/**
 * 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:
    
    int size(ListNode* head){
        int n = 0;
        while(head != NULL){
            n++;
            head = head->next;
        }
        return n;
    }
    
    ListNode* rotateRight(ListNode* head, int k) {
        if(head == NULL)
            return head;
        
        int n = size(head);
        int loop = k % n;
        loop = n - loop;
        
        if( n == 1 || loop == n)
            return head;
        
        int j=0;
        ListNode* temp = head;
        ListNode* firstAddress = head;
        
        while(temp != NULL){
            j++;
            if(j == loop){
                firstAddress = temp->next;
                temp->next = NULL;
                break;
            }
            temp = temp->next;
        }
        
        temp = firstAddress;
        while(temp->next != NULL){
            temp = temp->next;
        }
        
        temp->next = head;
        return firstAddress;
        
        
    }
};



================================================
FILE: Leetcode/Search in a row-column sorted Matrix.cpp
================================================
// https://practice.geeksforgeeks.org/problems/search-in-a-matrix-1587115621/1



bool search(vector<vector<int> > matrix, int n, int m, int x) 
{
    // code here
    int row=0;
    for(int i=0;i<n;i++){
        if(matrix[i][0] == x)
            return true;
        else if(matrix[i][0] > x)
        {
            row = i-1;  
            break;
        }else{
            row = i;
        }
    }
    
    if(row>=0){
        for(int i=0;i<m;i++){
            if(matrix[row][i] == x)
                return true;
        }
    }
    
    return false;
    
}


================================================
FILE: Leetcode/Single Number Leetcode solution.cpp
================================================
//https://leetcode.com/problems/single-number/



class Solution {
public:
    int singleNumber(vector<int>& nums) {
        int n = (int)nums.size();
        int a=0;
        for(int i=0;i<n;i++){
            //a= a^nums[i];
            a ^= nums[i];
        }
        return a;
    }
};


================================================
FILE: Leetcode/Sort Array By Parity.cpp
================================================
class Solution {
public:
    vector<int> sortArrayByParity(vector<int>& A) {
       vector<int> odd;
       vector<int> even;
        
        int n = (int)A.size();
        for(int i=0;i<n;i++){
            if(A[i]%2==0){even.push_back(A[i]);}
            else{odd.push_back(A[i]);}
        }
        
        even.insert(even.end(), odd.begin(), odd.end() );
        return even;
        
        
    }
};


================================================
FILE: Leetcode/Sort Colors.cpp
================================================
// https://leetcode.com/problems/sort-colors/

// or

// https://practice.geeksforgeeks.org/problems/sort-an-array-of-0s-1s-and-2s4231/1


class Solution {
public:
    void sortColors(vector<int>& nums) {
        
        // Method 1:
        //sort(nums.begin(), nums.end());
        
        
        // Method 2:
        
        /*
        int n = (int)nums.size();
        
        int f=0, s=0,t=0;
        for(int i=0;i<n;i++){
            if(nums[i]==0)
                f++;
            else if(nums[i]==1)
                s++;
            else
                t++;
        }
        
        for(int i=0;i<f;i++){
            nums[i]=0;
        }
        for(int i=f;i<f+s;i++){
            nums[i]=1;
        }
        for(int i=f+s;i<f+s+t;i++){
            nums[i]=2;
        }
        
        */
        
        
        // Method 3:
        
        int l=0;
        int m=0;
        int h=n-1;
        
        while(m<=h){
            int x = nums[m];
            if(x==0){
                swap(nums[l], nums[m]);
                l++;
                m++;
            }
            else if(x==1){
                m++;
            }
            else{
                swap(nums[h], nums[m]);
                h--;
            }
        }
        
    }
};


















================================================
FILE: Leetcode/Spirally traversing a matrix.cpp
================================================
Spirally traversing a matrix: https://practice.geeksforgeeks.org/problems/spirally-traversing-a-matrix-1587115621/1

class Solution
{   
public:     
    vector<int> spirallyTraverse(vector<vector<int> > matrix, int r, int c) 
    {
        // code here
        int top = 0;
        int bottom = r-1;
        int left = 0;
        int right = c-1;
        
        vector<int> ans;
        
        while(top<=bottom && left<=right){
            
            for(int i=left; i<=right ; i++)
                ans.push_back(matrix[top][i]);
            top++;
            
            for(int i=top;i<=bottom;i++)
                ans.push_back(matrix[i][right]);
            right--;
            
            if(top<=bottom){
                for(int i=right;i>=left;i--)
                    ans.push_back(matrix[bottom][i]);
                bottom--;
            }
            
            if(left<=right){
                for(int i=bottom;i>=top;i--)
                    ans.push_back(matrix[i][left]);
                left++;
            }
        }
        
        return ans;
    }
};


================================================
FILE: Leetcode/Square root.cpp
================================================
// https://practice.geeksforgeeks.org/problems/square-root/1



#include<bits/stdc++.h>
using namespace std;

long long int floorSqrt(long long int x);
  
  
// Function to find square root
// x: element to find square root
long long int floorSqrt(long long int x) 
{
    // Your code goes here
    int low = 1;
    int high = x;
    int ans = -1;
    
    while(low<=high){
        long long int mid = (low+high)/2;
        
        long long int sqr = mid*mid;
        
        if(sqr == x)
            return mid;
        else if(sqr < x){
            ans = mid;
            low = mid+1;
        }else{
            high = mid-1;
        }
    }
    
    return ans;
    
}

int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		long long n;
		cin>>n;
		cout << floorSqrt(n) << endl;
	}
    return 0;   
}


================================================
FILE: Leetcode/Subarray sum equals K.cpp
================================================
class Solution {
public:
    int subarraySum(vector<int>& nums, int k) {
        int n  =(int)nums.size();
        
        int count=0;
        
        unordered_map<int, int> prevSum;
        int sum=0;
        
        for(int i=0;i<n;i++){
            sum+=nums[i];
            
            if(sum==k)
                count++;
            
            if(prevSum.find(sum-k) != prevSum.end())
                count+=prevSum[sum-k];
            
            prevSum[sum]++;
        }
        
        return count;
    }
};


================================================
FILE: Leetcode/Trapping Rain Water.cpp
================================================
#include <iostream>
using namespace std;

// function to find the trapped water in between buildings
// arr: input array
// n: size of array
int trappingWater(int arr[], int n){
    
    int lmax[n]; lmax[0] = arr[0];
    for(int i=1;i<n;i++){
        int temp = max(arr[i], lmax[i-1]);
        lmax[i] = temp;
    }
    
    int rmax[n]; rmax[n-1] = arr[n-1];
    for(int i=n-2; i>=0 ;i--){
        int temp = max(arr[i], rmax[i+1]);
        rmax[i] = temp;
    }
    
    int water=0;
    for(int i=1;i<n-1;i++){
        water+= min(lmax[i], rmax[i]) - arr[i];
    }
    
    return water;
}


// { Driver Code Starts.

int main(){
    
    int t;
    //testcases
    cin >> t;
    
    while(t--){
        int n;
        
        //size of array
        cin >> n;
        
        int a[n];
        
        //adding elements to the array
        for(int i =0;i<n;i++){
            cin >> a[i];            
        }
        
        //calling trappingWater() function
        cout << trappingWater(a, n) << endl;
        
    }
    
    return 0;
}  // } Driver Code Ends


================================================
FILE: Leetcode/Tree/Balanced Binary Tree.cpp
================================================
// https://leetcode.com/problems/balanced-binary-tree/

/**
 * 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:
    
    int height(TreeNode* root){
        if(root == NULL)
            return 0;
        else 
            return max( height(root->left), height(root->right) ) +1;
    }
    
    void inorderUtil(TreeNode* root, bool & ans){
        if(root!=NULL){
            inorderUtil(root->left, ans);
            
            int lh = height(root->left);
            int rh = height(root->right);
            
            if(abs(lh-rh) >1)
                ans = ans && false;
            
            inorderUtil(root->right, ans);
        }
    }
    
    bool isBalanced(TreeNode* root) {
        bool ans = true;
        inorderUtil(root, ans);
        return ans;
    }
};


================================================
FILE: Leetcode/Tree/Binary Tree Inorder Traversal.cpp
================================================
// https://leetcode.com/problems/binary-tree-inorder-traversal/


/**
 * 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:
    
    void preorder(TreeNode* root, vector<int>  &ans){
        if(root!=NULL){
            ans.push_back(root->val);
            preorder(root->left, ans);
            preorder(root->right, ans);
        }
    }
    
    vector<int> inorderTraversal(TreeNode* root) {
        vector<int> ans;
        preorder(root, ans);
        return ans;
    }
};


================================================
FILE: Leetcode/Tree/Binary Tree Right Side View.cpp
================================================
// https://leetcode.com/problems/binary-tree-right-side-view/

/**
 * 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:
    vector<int> rightSideView(TreeNode* root) {
        vector<int> ans;
        queue<TreeNode*>q;
        q.push(root);
        
        if(root == NULL)
            return ans;
        while(1){
            int size = q.size();
            if(size==0)
                return ans;
            int data = 0;
            while(size>0){
                TreeNode* temp = q.front();
                q.pop();
                
                data = (temp->val);
                if(temp->left!=NULL)
                    q.push(temp->left);
                if(temp->right!=NULL)
                    q.push(temp->right);
                size--;
                   
            }
            ans.push_back(data);
        }
        return ans;
    }
};


================================================
FILE: Leetcode/Tree/Binary Tree Zigzag Level Order Traversal.cpp
================================================
// https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/

vector<vector<int>> zigzagLevelOrder(TreeNode* root) {
        vector<vector<int>> ans;
        queue<TreeNode*> q;
        q.push(root);
        
        int count = 0;
        if(root == NULL)
            return ans;
        
        while(1){
            int size = q.size();
            if(size == 0)
                return ans;
            count++;
            vector<int>data;
            
            while(size>0){
                TreeNode* temp = q.front();
                q.pop();

                data.push_back(temp->val);
                if(temp->left != NULL)
                    q.push(temp->left);
                if(temp->right != NULL)
                    q.push(temp->right);
                size--;
            }
            if(count%2==0)
                reverse(data.begin(), data.end());
            ans.push_back(data);
            
        }
        return ans;
    
    }


================================================
FILE: Leetcode/Tree/Children Sum Parent.cpp
================================================
// https://practice.geeksforgeeks.org/problems/children-sum-parent/1/

int isSumProperty(Node *root)
{
  if( root == NULL  || (root->left == NULL && root->right==NULL))
    return 1;
  
  int left_sum = 0, right_sum = 0;
  if(root->left != NULL)
    left_sum = root->left->data;
  if(root->right != NULL)
    right_sum = root->right->data;
 
  if( root->data == (left_sum+right_sum) &&
      isSumProperty(root->left) &&
      isSumProperty(root->right) ){
          return 1;
      }
  else
     return 0;
 
}


================================================
FILE: Leetcode/Tree/Construct Binary Tree from Preorder and Inorder Traversal.cpp
================================================
// https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/

/**
 * 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:
    
    int preIndex = 0;
    
    TreeNode* buildTreeUtil(vector<int>& preorder, vector<int>& inorder, int is, int ie){
        if(is > ie)
            return NULL;
        
        TreeNode* root = new TreeNode(preorder[preIndex]);
        preIndex++;
        
        
        int inIndex;
        for(int i=is; i<=ie; i++){
            if(inorder[i] == root->val){
                inIndex = i;
                break;
            }
        }
        
        root->left = buildTreeUtil(preorder, inorder, is, inIndex-1);
        root->right = buildTreeUtil(preorder, inorder, inIndex+1, ie);
        
        return root;
        
    }
    
    TreeNode* buildTree(vector<int>& preorder, vector<int>& inorder) {
        TreeNode* ans = buildTreeUtil(preorder, inorder, 0, inorder.size()-1);
        return ans;
    }
};


================================================
FILE: Leetcode/Tree/Diameter of Binary Tree.cpp
================================================
// https://leetcode.com/problems/diameter-of-binary-tree/

/**
 * 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:
    
    int res = 0;
    
    int height(TreeNode* root){
        if(root == NULL)
            return 0;
        
        int lh = height( root-> left);
        int rh = height( root-> right);
        
        res = max(res, 1+lh+rh);
        
        return 1+ max(lh, rh);
        
    }
    
    int diameterOfBinaryTree(TreeNode* root) {
        int data = height(root);
        return res-1;
    }
};


================================================
FILE: Leetcode/Tree/Invert Binary Tree.cpp
================================================
// https://leetcode.com/problems/invert-binary-tree/

/**
 * 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) {
        stack <TreeNode*> st;
        st.push(root);
        
        while(!st.empty()){
            TreeNode* node = st.top();
            st.pop();
            
            if(node != NULL){
                st.push(node->left);
                st.push(node->right);
                swap(node->left, node->right);
            }
        }
        
        return root;
    }
};


================================================
FILE: Leetcode/Tree/Level Order Traversal.cpp
================================================
// https://leetcode.com/problems/binary-tree-level-order-traversal/

vector<vector<int>> levelOrder(TreeNode* root) {
        vector<vector<int>> ans;
        queue<TreeNode*>q;
        q.push(root);
        
        if(root == NULL)
            return ans;
        while(1){
            int size = q.size();
            if(size==0)
                return ans;
            vector<int>data;
            while(size>0){
                TreeNode* temp = q.front();
                q.pop();
                
                data.push_back(temp->val);
                if(temp->left!=NULL)
                    q.push(temp->left);
                if(temp->right!=NULL)
                    q.push(temp->right);
                size--;
                   
            }
            ans.push_back(data);
        }
        return ans;
    }


================================================
FILE: Leetcode/Tree/Lowest Common Ancestor of a Binary Tree.cpp
================================================
// https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/


//                  METHOD - 01


/**
 * 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:
    
    bool findPath(TreeNode* root,  vector<TreeNode*> &path, TreeNode* n){
        if(root == NULL)
            return false;
        path.push_back(root);
        if(root == n) return true;
        
        if( findPath(root->left, path, n) || findPath(root->right, path, n) )
            return true;
        
        path.pop_back();
        return false;
    }
    

    TreeNode* lowestCommonAncestor(TreeNode* root, TreeNode* p, TreeNode* q) {
      
        vector<TreeNode*> path1, path2;
        if( !findPath(root, path1, p) || !findPath(root, path2, q)  )
            return NULL;
        TreeNode* ans = NULL;
        for(int i=0; i<path1.size() && i<path2.size(); i++){
            if(path1[i] == path2[i])
                ans = path2[i];
        }
        return ans;
        
    }

};






//                  METHOD - 02



/**
 * 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 == NULL)
            return NULL;
        if(root == p || root == q)
            return root;
        
        TreeNode* lca1 = lowestCommonAncestor(root->left, p, q);
        TreeNode* lca2 = lowestCommonAncestor(root->right, p, q);
        
        if(lca1 != NULL && lca2 != NULL)
            return root;
        if(lca1 != NULL)
            return lca1;
        else
            return lca2;
        
    }

};





================================================
FILE: Leetcode/Tree/Maximum Depth of Binary Tree.cpp
================================================
// https://leetcode.com/problems/maximum-depth-of-binary-tree/

class Solution {
public:
    int maxDepth(TreeNode* root) {
        if(root == NULL)
            return 0;
        else
            return max( maxDepth(root->left), maxDepth(root->right) ) + 1;
    }
};


================================================
FILE: Leetcode/Tree/Populating Next Right Pointers in Each Node.cpp
================================================
// https://leetcode.com/problems/populating-next-right-pointers-in-each-node/

/*
// Definition for a Node.
class Node {
public:
    int val;
    Node* left;
    Node* right;
    Node* next;

    Node() : val(0), left(NULL), right(NULL), next(NULL) {}

    Node(int _val) : val(_val), left(NULL), right(NULL), next(NULL) {}

    Node(int _val, Node* _left, Node* _right, Node* _next)
        : val(_val), left(_left), right(_right), next(_next) {}
};
*/

class Solution {
public:
    Node* connect(Node* root) {
        if(root == NULL)
            return root;
        
        queue<Node*>q;
        q.push(root);
        
        while(!q.empty()){
            int size = q.size();
            if( size == 0)
                return root;
            
            while(size>0){
                Node* temp;
                
                if(size>1){
                    temp = q.front();
                    q.pop();
                    
                    Node* nextAdd = q.front();
                    temp->next = nextAdd;
                    
                }
                else{
                    temp = q.front();
                    q.pop();
                }
                
                if(temp->left != NULL)
                    q.push(temp->left);
                if(temp->right != NULL)
                    q.push(temp->right);
                
                size--;
                
            }
        }
        
        return root;
    }
};


================================================
FILE: Leetcode/Tree/Subtree of Another Tree.cpp
================================================
// https://leetcode.com/problems/subtree-of-another-tree/

/**
 * 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:
    
    bool ans = false;
    
    
    bool match(TreeNode* root, TreeNode* subRoot){
        
        if(root!=NULL && subRoot!=NULL){
            bool a = match(root->left, subRoot->left);
            bool b = match(root->right, subRoot->right);
            
            if( (root->val == subRoot->val) && a && b ){
                return true;
            }else
                return false;
        }
        else if(root==NULL && subRoot==NULL)
            return true;
        else
            return false;
    }
    
    
    void inorder(TreeNode* root, TreeNode* subRoot){
        if(root!=NULL){
            inorder(root->left, subRoot);
            
            bool x = match(root, subRoot);
            if(x){ans = x;}
            
            inorder(root->right, subRoot);
        }
    }
    
    bool isSubtree(TreeNode* root, TreeNode* subRoot) {
        inorder(root, subRoot);
        return ans;
    }
};


================================================
FILE: Leetcode/Tree/Symmetric Tree.cpp
================================================
// https://leetcode.com/problems/symmetric-tree/

/**
 * 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:
    
    bool match(TreeNode* root1, TreeNode* root2){
        if(root1 != NULL && root2 != NULL){
            bool a = match(root1->left, root2->right);
            bool b = match(root1->right, root2->left);
            
            if((root1->val == root2->val) && a && b)
                return true;
            else
                return false;
            
        }
        else if(root1 == NULL && root2 == NULL){
            return true;
        }else
            return false;
    }
    
    bool isSymmetric(TreeNode* root) {
        if(root == NULL)
            return true;
        
        return match(root->left, root->right);
    }
};


================================================
FILE: Leetcode/Tree/Vertical Width of a Binary Tree .cpp
================================================
// https://practice.geeksforgeeks.org/problems/vertical-width-of-a-binary-tree/1



/*Structure of node of binary tree is as follows
struct Node
{
    int data;
    struct Node* left;
    struct Node* right;
    
    Node(int x){
        data = x;
        left = right = NULL;
    }
};
*/

unordered_set<int>st;

void inorderUtil(Node* root, int hd){
    if(root != NULL){
        inorderUtil(root->left, hd-1);
        st.insert(hd);
        inorderUtil(root->right, hd+1);
    }
}

//Function to find the vertical width of a Binary Tree.
int verticalWidth(Node* root)
{
    // Code here
    st.clear();
    inorderUtil(root, 0);
    return st.size();
    
}


================================================
FILE: Leetcode/Tree/same Tree.cpp
================================================
// https://leetcode.com/problems/same-tree/


/**
 * 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:
    
    void inorder(TreeNode* root, vector<int>&v){
        if(root!=NULL){
            inorder(root->left, v);
            v.push_back(root->val);
            inorder(root->right, v);
        }else
            v.push_back(100000);
    }
    
    void preorder(TreeNode* root, vector<int>&v){
        if(root!=NULL){
            v.push_back(root->val);
            preorder(root->left, v);
            preorder(root->right, v);
        }else
            v.push_back(100000);
    }
    
    bool isSameTree(TreeNode* p, TreeNode* q) {
        
        vector<int> inp, inq, prep, preq;
        inorder(p, inp);
        inorder(q, inq);
        
        preorder(p, prep);
        preorder(q, preq);
        
        if(inp == inq  && prep == preq)
            return true;
        else
            return false;
    }
};


// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Recursive Solution

class Solution {
public:
    bool isSameTree(TreeNode* p, TreeNode* q) {
        if(p==NULL && q==NULL)
            return true;
        if(p==NULL || q==NULL)
            return false;
        return ( p->val == q->val  && 
                 isSameTree( p->left, q->left ) && 
                 isSameTree( p->right, q->right )  );
    }
};


================================================
FILE: Leetcode/count 1's in binary array.cpp
================================================
// https://practice.geeksforgeeks.org/problems/count-1s-in-binary-array-1587115620/1



#include <bits/stdc++.h>
using namespace std;

// Function to count number of Ones
// arr: input array 
// N: size of input array
int countOnes(int arr[], int N)
{
    
    // Your code here
    int low=0;
    int high=N-1;
    
    while(low<=high){
        int mid = (low+high)/2;
        
        if(arr[mid]==0){
            high = mid-1;
        }
        else{
            if(arr[mid+1]==0 || mid==N-1){
                return mid+1;
            }else{
                low = mid+1;
            }
        }
        
         
    }
    
    return 0;
    
}

int main()
{
    int t;
    cin>>t;
    
    while(t--)
    {
        int n;
        cin>>n;
        int *arr = new int[n]; 
        for(int i = 0; i < n; i++)
            cin>>arr[i];
        
        cout <<countOnes(arr, n)<<endl;
    }
    return 0;
}




/*



#include <bits/stdc++.h>
using namespace std;

// Function to count number of Ones
// arr: input array 
// N: size of input array
int countOnes(int arr[], int N)
{
    
    // Your code here
    int low= 0;
    int high = N-1;
    
    while(low<=high){
        int mid = (low+high) /2;
        
        if(arr[mid]==0){
            if(arr[mid-1]==1 || mid == 0){
                return mid;
            }else{
                high = mid-1;
            }
            
        }
        else{
            
            if(arr[mid+1]==0 || mid == N-1){
                return mid+1;
            }else{
                low = mid+1;
            }
        }
    }
    
    return 0;
    
}

int main()
{
    int t;
    cin>>t;
    
    while(t--)
    {
        int n;
        cin>>n;
        int *arr = new int[n]; 
        for(int i = 0; i < n; i++)
            cin>>arr[i];
        
        cout <<countOnes(arr, n)<<endl;
    }
    return 0;
}


*/


================================================
FILE: Leetcode/linked-list-cycle.cpp
================================================
// https://leetcode.com/problems/linked-list-cycle/


/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode(int x) : val(x), next(NULL) {}
 * };
 */
class Solution {
public:
    bool hasCycle(ListNode *head) {
        if(head == NULL || head->next == NULL){
            return false;
        }
        
        ListNode *slow = head;
        ListNode *fast = head->next;
        
        while(slow!=fast){
            if(fast==NULL || fast->next == NULL){
                return false;
            }
            slow = slow->next;
            fast = fast->next->next;
        }
        return true;
    }
};


================================================
FILE: Leetcode/linkedlist/Copy List with Random Pointer.cpp
================================================
// https://leetcode.com/problems/copy-list-with-random-pointer/


/*
// Definition for a Node.
class Node {
public:
    int val;
    Node* next;
    Node* random;
    
    Node(int _val) {
        val = _val;
        next = NULL;
        random = NULL;
    }
};
*/

class Solution {
public:
    Node* copyRandomList(Node* head) {
        if( head == NULL) return head;
        Node* newhead = new Node(0);
        Node* new_curr = newhead;
        Node* curr = head;
        unordered_map<Node*, Node*> umap;
        
        while(curr){
            Node* temp = new Node(curr->val);
            umap.insert({curr, temp});
            
            new_curr->next = temp;
            new_curr = new_curr->next;
            curr = curr->next;
        }
        curr = head;
        new_curr = newhead->next;
        
        while(curr){
            Node* random = curr->random;
            Node* newNode = umap[random];
            new_curr->random = newNode;
            
            new_curr = new_curr->next;
            curr = curr->next;
        }
        
        return newhead->next;
    }
};


================================================
FILE: Leetcode/linkedlist/Delete Node in a Linked List.cpp
================================================
// https://leetcode.com/problems/delete-node-in-a-linked-list/

class Solution {
public:
    void deleteNode(ListNode* node) {
        ListNode* curr = node->next;
        node->val = curr->val;
        node->next = curr->next;
    }
};


================================================
FILE: Leetcode/linkedlist/Intersection of Two Linked Lists.cpp
================================================
// https://leetcode.com/problems/intersection-of-two-linked-lists/

/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode(int x) : val(x), next(NULL) {}
 * };
 */
class Solution {
public:
    ListNode *getIntersectionNode(ListNode *headA, ListNode *headB) {
        ListNode* curr = headA;
        int a =0, b=0;
        while(curr){
            a++;
            curr = curr->next;
        }
        curr =headB;
        while(curr){
            b++;
            curr = curr->next;
        }
        int diff = abs(a-b);
        if(a<b){
            while(diff--){
                headB = headB->next;
            }
        }else{
            while(diff--){
                headA = headA->next;
            }
        }
        
        while(headA and headB){
            if(headA == headB){
                return headA;
            }
            headA = headA->next;
            headB = headB->next;
        }
        return NULL;
    }
};


================================================
FILE: Leetcode/linkedlist/Linked List Cycle II.cpp
================================================
// https://leetcode.com/problems/linked-list-cycle-ii/

/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode(int x) : val(x), next(NULL) {}
 * };
 */
class Solution {
public:
    ListNode *detectCycle(ListNode *head) {
        if(head == NULL) return NULL;
        ListNode* slow = head, *fast = head, *entry = head;
        while(fast->next != NULL && fast->next->next != NULL){
            slow = slow->next;
            fast = fast->next->next;
            
            if(slow == fast){
                while(entry != slow){
                    slow = slow->next;
                    entry = entry->next;
                }
                return slow;
            }
        }
        return NULL;
        
        /*
        
        unordered_set<ListNode*> set;
        ListNode* curr = head;
        while(curr != NULL){
            if(set.find(curr) != set.end()){
                return curr;
            }else{
                set.insert(curr);
                curr = curr->next;
            }
        }
        return NULL;
        
        */
    }
};


================================================
FILE: Leetcode/linkedlist/Merge Two Sorted Lists.cpp
================================================
// https://leetcode.com/problems/merge-two-sorted-lists/

/**
 * 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* mergeTwoLists(ListNode* list1, ListNode* list2) {
        ListNode* head;
        
        if(list1->val <= list2->val){
              head = list1;
             list1 = list1->next;
        }else{
             head = list2;
            list2 = list2->next;
        }
        
        ListNode* curr = head;

        while(list1 != NULL && list2 != NULL){
            if(list1->val <= list2->val){
                curr->next = list1;
                list1 = list1->next;
            }else{
                curr->next = list2;
                list2 = list2->next;
            }
            curr = curr->next;
        }
        
        if(list1 != NULL) curr->next = list1;
        if(list2 != NULL) curr->next = list2;
            
        return head;
    }
};


================================================
FILE: Leetcode/linkedlist/Palindrome Linked List.cpp
================================================
// https://leetcode.com/problems/palindrome-linked-list/

/**
 * 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:
    bool isPalindrome(ListNode* head) {
        ListNode* slow = head, *fast = head;
        while(fast and fast->next){
            slow = slow->next;
            fast = fast->next->next;
        }
        if(fast != NULL and fast->next == NULL ){
            slow = slow->next;
        }
        
        ListNode* prev = NULL;
        while(slow and slow->next){
            ListNode* temp = slow->next;
            slow->next = prev;
            prev = slow;
            slow = temp;
        }
        if(slow != NULL){slow->next = prev;}
        fast = head;
        while(slow and fast){
            if(slow->val != fast->val)
                return false;
            slow = slow->next;
            fast = fast->next;
        }
        return true;
        
    }
};


================================================
FILE: Leetcode/linkedlist/Remove Duplicates from Sorted List.cpp
================================================
// https://leetcode.com/problems/remove-duplicates-from-sorted-list/

class Solution {
public:
    ListNode* deleteDuplicates(ListNode* head) {
        ListNode* curr = head;
        while(curr != NULL && curr->next != NULL){
            if(curr->val == curr->next->val){
                // same 
                ListNode* temp = curr->next;
                curr->next = temp->next;
                delete(temp);
            }else{
                curr = curr->next;
            }
        }
        return head;
    }
};


================================================
FILE: Leetcode/linkedlist/Remove Nth Node From End of List.cpp
================================================
// https://leetcode.com/problems/remove-nth-node-from-end-of-list/

/**
 * 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* removeNthFromEnd(ListNode* head, int n) {
        ListNode *slow = head, *fast = head;
        while(n--){
            fast = fast->next;
        }
        if(fast == NULL) return slow->next;
        
        while(fast->next != NULL){
            slow = slow->next;
            fast = fast->next;
        }
        
        slow->next = slow->next->next;
        return head;
        
    }
};


================================================
FILE: Leetcode/linkedlist/Remove duplicates from an unsorted linked list.cpp
================================================
// https://practice.geeksforgeeks.org/problems/remove-duplicates-from-an-unsorted-linked-list/0

/*
The structure of linked list is the following

struct Node {
  int data;
  struct Node *next;
  Node(int x) {
    data = x;
    next = NULL;
  }
};
*/


class Solution
{
    public:
    //Function to remove duplicates from unsorted linked list.
    Node * removeDuplicates( Node *head) 
    {
     // your code goes here
        unordered_set<int>seen;
        Node* curr = head;
        
        if(curr == NULL)
            return head;
        else
            seen.insert(curr->data);
            
        while(curr != NULL && curr->next != NULL){
            if(seen.find(curr->next->data) != seen.end()){
                // same 
                curr->next = curr->next->next;
            }else{
                // not same
                seen.insert(curr->next->data);
                curr = curr->next;
            }
        }
        return head;
    }
};


================================================
FILE: Leetcode/linkedlist/Reverse Linked List.cpp
================================================
// https://leetcode.com/problems/reverse-linked-list/

/**
 * 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* reverseList(ListNode* head) {
        ListNode* prev = NULL, *curr = head;
        while(curr != NULL){
            ListNode *temp = curr->next;
            curr->next = prev;
            prev = curr;
            curr = temp;
        }
        return prev;
    }
};


================================================
FILE: Leetcode/linkedlist/Sort List.cpp
================================================
// https://leetcode.com/problems/sort-list/

/**
 * 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* Mid(ListNode* head){
        ListNode* slow = head;
        ListNode* fast = head;
        
        while(fast->next != NULL and fast->next->next != NULL){
            slow = slow->next;
            fast = fast->next->next;
        }
        return slow;
    }
    
    ListNode* mergeSortedList(ListNode *p1, ListNode *p2){
        if(p1 == NULL or p2 == NULL){
            return (p1==NULL) ? p2 : p1;
        }
        
        ListNode * ans = new ListNode(0);
        ListNode* curr = ans;
        
        while(p1 != NULL and p2 != NULL){
            if(p1->val < p2->val){
                curr->next = p1;
                p1= p1->next;
            }else{
                curr->next = p2;
                p2 = p2->next;
            }
            curr = curr->next;
        }
        
        if(p1 != NULL or p2 != NULL){
            curr->next = (p1 != NULL) ?  p1 : p2;
        }
        return ans->next;
    }
    
    ListNode* sortList(ListNode* head) {
        if( head == NULL or head->next == NULL) return head;
        ListNode* mid = Mid(head);
        ListNode* newhead = mid->next;
        mid->next = NULL;
        
        ListNode* left_half = sortList(head);
        ListNode* right_half = sortList(newhead);
        
        return mergeSortedList(left_half, right_half);
    }
};


================================================
FILE: Leetcode/linkedlist/Swap Nodes in Pairs.cpp
================================================
// https://leetcode.com/problems/swap-nodes-in-pairs/

/**
 * 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* swapPairs(ListNode* head) {
        if(head == NULL || head->next == NULL) return head;
        ListNode *curr = head->next->next;
        ListNode * prev = head;
        head = head->next;
        head->next = prev;
        
        while(curr != NULL && curr->next != NULL){
            prev->next = curr->next;
            prev = curr;
            ListNode * temp = curr->next->next;
            curr->next->next = curr;
            curr = temp;
        }
        
        prev->next = curr;
        return head;
    }
};


================================================
FILE: Leetcode/linkedlist/Swapping Nodes in a Linked List.cpp
================================================
// https://leetcode.com/problems/swapping-nodes-in-a-linked-list/

/**
 * 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* swapNodes(ListNode* head, int k) {
        ListNode* slow = head,  *fast = head;
        while(--k){
            fast = fast->next;
        }
        ListNode *first = fast;
        
        while(fast->next != NULL){
            slow = slow->next;
            fast = fast->next;
        }
        
        swap(first->val, slow->val);
        return head;
    }
};


================================================
FILE: Leetcode/stack/Evaluate Reverse Polish Notation.cpp
================================================
// https://leetcode.com/problems/evaluate-reverse-polish-notation/

class Solution {
public:
    int evalRPN(vector<string>& tokens) {
        stack<int>st;
        for(auto x: tokens){
            if(x == "+" || x == "-" || x =="/" || x == "*"){
                int op2 = st.top(); st.pop();
                int op1 = st.top(); st.pop();
                
                if(x == "+"){
                    st.push(op1 + op2);
                }
                if(x == "-"){
                    st.push(op1 - op2);
                }
                if(x == "*"){
                    st.push(op1 * op2);
                }
                if(x == "/"){
                    st.push(op1 / op2);
                }
            }
            else{
                stringstream ss(x);
                int data;
                ss >> data;
                st.push(data);
            }
        }
        
        return st.top();
    }
};


================================================
FILE: Leetcode/stack/Implement Queue using Stacks.cpp
================================================
// https://leetcode.com/problems/implement-queue-using-stacks/

class MyQueue {

private:
    stack<int>input, output;
    
public:
    MyQueue() {
        
    }
    
    void push(int x) {
        input.push(x);
    }
    
    int pop() {
        int val = peek();
        output.pop();
        return val;
    }
    
    int peek() {
        if( output.empty() ){
            while( input.empty() != true ){
                output.push(input.top());
                input.pop();
            }
        }
        
        return output.top();
    }
    
    bool empty() {
        return input.empty() && output.empty();
    }
};

/**
 * Your MyQueue object will be instantiated and called as such:
 * MyQueue* obj = new MyQueue();
 * obj->push(x);
 * int param_2 = obj->pop();
 * int param_3 = obj->peek();
 * bool param_4 = obj->empty();
 */


================================================
FILE: Leetcode/stack/Implement Stack using Queues.cpp
================================================
// https://leetcode.com/problems/implement-stack-using-queues/

class MyStack {
public:
    queue<int>q1,q2;
    
    
    MyStack() {
        
    }
    
    void push(int x) {
        while(!q1.empty()){
            q2.push(q1.front());
            q1.pop();
        }
        q1.push(x);
        while(!q2.empty()){
            q1.push(q2.front());
            q2.pop();
        }
        
    }
    
    int pop() {
        int val = q1.front();
        q1.pop();
        return val;
        
    }
    
    int top() {
        return q1.front();
    }
    
    bool empty() {
        return q1.empty();
    }
};

/**
 * Your MyStack object will be instantiated and called as such:
 * MyStack* obj = new MyStack();
 * obj->push(x);
 * int param_2 = obj->pop();
 * int param_3 = obj->top();
 * bool param_4 = obj->empty();
 */


================================================
FILE: Leetcode/stack/Largest Rectangle in Histogram.cpp
================================================
// https://leetcode.com/problems/largest-rectangle-in-histogram/

class Solution {
public:
    
    vector<int> previous_smaller(vector<int>& heights){
        vector<int> ans;
        stack<int>st;
        int n = heights.size();
        
        for(int i=0; i<n; i++){
            while(st.empty() == false && heights[st.top()] >= heights[i] ){
                st.pop();
            }
            int ele = (st.empty()) ? -1 : st.top();
            ans.push_back(ele);
            st.push(i);
        }
        return ans;
    }

    vector<int> next_smaller(vector<int>& heights){
        vector<int> ans;
        stack<int>st;
        int n = heights.size();
        
        for(int i=n-1; i>=0; i--){
            while(st.empty() == false && heights[st.top()] >= heights[i] ){
                st.pop();
            }
            int ele = (st.empty()) ? n : st.top();
            ans.push_back(ele);
            st.push(i);
        }
        reverse(ans.begin(), ans.end());
        return ans;
    }
    
    int largestRectangleArea(vector<int>& heights) {
        int res = 0;
        int n = heights.size();
        vector<int>ps = previous_smaller(heights);
        vector<int>ns = next_smaller(heights);
        
        for(int i=0; i<n; i++){
            int curr = ( ns[i] - ps[i] -1 ) * heights[i];
            res = max(res , curr);
        }
        return res;
    }
};




================================================
FILE: Leetcode/stack/Min Stack.cpp
================================================
// https://leetcode.com/problems/min-stack/

class MinStack {
public:
    
    stack<int>st, s2;
    MinStack() {
        
    }
    
    void push(int val) {
        if( s2.empty() || val <= s2.top() ){
            s2.push(val);
        }
        
        st.push(val);
    }
    
    void pop() {
        
        if(st.top() == s2.top()){
            s2.pop();
        }
        st.pop();
        
    }
    
    int top() {
        return st.top();
    }
    
    int getMin() {
        return s2.top();
    }
};

/**
 * Your MinStack object will be instantiated and called as such:
 * MinStack* obj = new MinStack();
 * obj->push(val);
 * obj->pop();
 * int param_3 = obj->top();
 * int param_4 = obj->getMin();
 */


================================================
FILE: Leetcode/stack/Next Greater Element I.cpp
================================================
// https://leetcode.com/problems/next-greater-element-i/

class Solution {
public:
    vector<int> nextGreaterElement(vector<int>& nums1, vector<int>& nums2) {
        unordered_map<int,int>umap;
        stack<int>st;
        int n = nums2.size();
        
        for(int i=n-1; i>=0; i--){
            int ele = nums2[i];
            while(!st.empty() && st.top() <= ele){
                st.pop();
            }
            int res = (st.empty()) ? -1 : st.top();
            umap.insert({ele, res});
            st.push(ele);
        }
        
        vector<int> ans;
        for(auto x: nums1){
            ans.push_back(umap[x]);
        }
        
        return ans;
    }
};


================================================
FILE: Leetcode/stack/Online Stock Span.cpp
================================================
// https://leetcode.com/problems/online-stock-span/

class StockSpanner {
public:
    stack<pair<int,int>>st; // price, span
    StockSpanner() {
        
    }
    
    int next(int price) {
        int span = 1;
        
        while(!st.empty() && st.top().first <= price){
            span += st.top().second;
            st.pop();
        }
        
        st.push({price, span});
        return span;
    }
};

/**
 * Your StockSpanner object will be instantiated and called as such:
 * StockSpanner* obj = new StockSpanner();
 * int param_1 = obj->next(price);
 */


================================================
FILE: Leetcode/stack/Remove All Adjacent Duplicates In String.cpp
================================================
// https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string/

class Solution {
public:
    string removeDuplicates(string s) {
        int n = s.size(), i=0;
        stack<char>st;
        
        while(i<n){
            if(st.empty() || st.top() != s[i])
                st.push(s[i]);
            else
                st.pop();
            
            i++;
        }
        
        string ans = "";
        while(!st.empty()){
            char ele = st.top();
            st.pop();
            
            ans += ele;
        }
        
        reverse(ans.begin(), ans.end());
        return ans;
    }
};


================================================
FILE: Leetcode/stack/Remove All Adjacent Duplicates in String II.cpp
================================================
// https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string-ii/

class Solution {
public:
    string removeDuplicates(string s, int k) {
        
        vector<pair<char, int>>st;
        for(auto c : s){
            if(st.size() == 0 || st.back().first != c ){
                st.push_back({c, 1});
            }
            else{
                st.back().second++;
            }
            
            if(st.back().second == k){
                st.pop_back();
            }
        }
        
        string res ;
        for(auto x: st){
            res.append(x.second, x.first);
        }
            
        return res;
    }
};


================================================
FILE: Leetcode/stack/Reverse First K elements of Queue.cpp
================================================
// https://practice.geeksforgeeks.org/problems/reverse-first-k-elements-of-queue/1/

// { Driver Code Starts
// Initial Template for C++

#include <bits/stdc++.h>
using namespace std;
queue<int> modifyQueue(queue<int> q, int k);
int main() {
    int t;
    cin >> t;
    while (t-- > 0) {
        int n, k;
        cin >> n >> k;
        queue<int> q;
        while (n-- > 0) {
            int a;
            cin >> a;
            q.push(a);
        }
        queue<int> ans = modifyQueue(q, k);
        while (!ans.empty()) {
            int a = ans.front();
            ans.pop();
            cout << a << " ";
        }
        cout << endl;
    }
}// } Driver Code Ends


// User function Template for C++

// Function to reverse first k elements of a queue.
queue<int> modifyQueue(queue<int> q, int k) {
    // add code here.
    
    queue<int> ans;
    stack<int>st;
    
    while(k--){
        st.push(q.front());
        q.pop();
    }
    
    while(!st.empty()){
        ans.push(st.top());
        st.pop();
    }
    
    while(!q.empty()){
        ans.push(q.front());
        q.pop();
    }
    
    return ans;
}


================================================
FILE: Leetcode/stack/Valid Parentheses.cpp
================================================
// https://leetcode.com/problems/valid-parentheses/

class Solution {
public:
    bool isValid(string s) {
        stack<char>st;
        for(auto c : s){
            if(st.empty()){
                st.push(c);
            }
            else if( (st.top() == '(' && c == ')') || 
                     (st.top() == '[' && c == ']') || 
                     (st.top() == '{' && c == '}') ){
                st.pop();
            }
            else{
                st.push(c);
            }
        }
        
        if(st.size() == 0)
            return true;
        
        return false;
    }
};


================================================
FILE: Leetcode/string/Find the Index of the First Occurrence in a String.cpp
================================================
// https://leetcode.com/problems/find-the-index-of-the-first-occurrence-in-a-string/
// Pattern Matching Algorithm by using KMP Algorithm

class Solution {
public:
    
    vector<int> fillLPS(string str){
        int n = str.size();
        vector<int>lps(n,0);
        int len =0, i = 1;
        lps[0]=0;
        while(i<n){
            if(str[len] == str[i]){
                len++;
                lps[i] = len;
                i++;
            }else{
                if(len == 0){
                    lps[i]=0;
                    i++;
                }else{
                    len = lps[len-1];
                }
            }
        }
        return lps;
    }
    
    int strStr(string haystack, string needle) {
        int n = haystack.size();
        int m = needle.size();
        vector<int>lps = fillLPS(needle);
        int i=0, j=0;
        while(i<n){
            if(haystack[i] == needle[j]){
                i++;
                j++;
                if(j==m){
                    return i-j;
                }
            }
            else if(i<n && haystack[i] != needle[j]){
                if(j==0)
                    i++;
                else{
                    j = lps[j-1];
                }
            }
        }
        return -1;
    }
    
    
};



/* SOLUTION NAIVE APPROACH */

class Solution {
public:
    int strStr(string haystack, string needle) {
        int i=0, j=0, n= haystack.size(), m = needle.size();
        if(haystack == needle) return 0;
        while(i<n){
            if(haystack[i] == needle[j]){
                int index = i;
                string temp = "";
                while(i<n && j<m && haystack[i] == needle[j]){
                    temp += haystack[i];
                    i++;
                    j++;
                }
                if(temp == needle){
                    return index;
                }else{
                    i=index+1;
                    j = 0;
                }

            }else{
                i++;
            }
        }
        return -1;
    }
};


================================================
FILE: Leetcode/string/Gas Station.cpp
================================================
// https://leetcode.com/problems/gas-station/

Solution {
public:
    int canCompleteCircuit(vector<int>& gas, vector<int>& cost) {
        int totalDiff =0, n = gas.size(), fuel =0, index =0;
        for(int i=0; i<n; i++){
            int diff = gas[i] - cost[i];
            totalDiff += diff;
            fuel += diff;
            if(fuel < 0){
                index = i+1;
                fuel = 0;
            }
        }
        return (totalDiff < 0) ? -1 : index;
    }
};


================================================
FILE: Leetcode/string/Maximum Ice Cream Bars.cpp
================================================
// https://leetcode.com/problems/maximum-ice-cream-bars/

class Solution {
public:
    int maxIceCream(vector<int>& costs, int coins) {
        int ans = 0;
        sort(costs.begin(), costs.end());
        for(auto x: costs){
            if(coins >= x){
                ans++; coins-=x;
            }
        }
        return ans;
    }
};


================================================
FILE: Leetcode/sum of numbers in string.cpp
================================================
// https://practice.geeksforgeeks.org/problems/sum-of-numbers-in-string/0

#include <iostream>
using namespace std;

int findSum(string s)
{
	// Your code here
	int n = (int)s.size();
	int num=0;
	int sum=0;
	for(int i=0;i<n;i++){
	    
	    if(s[i]>='0' && s[i]<='9')
	        num = num*10 + (s[i]-'0');
	    else{
	        sum += num;
	        num = 0;
	    }
	}
	
	return sum+num;
}

int main()
{
	int t;
	cin>>t;
	while(t--)
	{
	    string str;
	    cin>>str;
	    cout << findSum(str);
        cout<<endl;
	}
	return 0;
}


================================================
FILE: README.md
================================================
# Competitive Programming by </ <a href="https://www.youtube.com/channel/UCbW63uLlDnsL7l992Z9nF_Q/" target="_blank">HELLO WORLD </a> >

[Hello World](https://www.youtube.com/channel/UCbW63uLlDnsL7l992Z9nF_Q/)

This section will provide you the pdf of my lecture and codes.

I have Youtube channel named - "Hello World" 


My channel contains Courses on 

* Competitive Programming
* Data Structure
* Algorithms like sorting , searching , graph etc
* C++ Language
* And lots of stuffs 

You can contact me on my Email ID : Helloworldbyprince@gmail.com


================================================
FILE: STL/Array_Algorithms_in_stl.cpp
================================================
//  DATA STRUCTURES.cpp
//
//  Created by Prince  Kumar on 26/06/2020.
//  Copyright © 2020
Download .txt
gitextract_md51_btr/

├── 35_hacker_two_strings.cpp
├── 36_codechef_Encoding_message.cpp
├── 37_codechef_spell_bob.cpp
├── 38_codechef_fits_square_in_triangle.cpp
├── 39_codechef_chef_and_Eid.cpp
├── 40_codechef_chef_judges_competition.cpp
├── 41_codechef_chef_and_glove.cpp
├── 42_codechef_the_great_run.cpp
├── 43_codechef_attendance.cpp
├── 44_codechef_making_a_meal.cpp
├── 45_codechef_uncle_johny.cpp
├── 46_drink_codeforce.cpp
├── 47_candles_codeforces.cpp
├── 49_two_buttons_codeforces.cpp
├── 50_vanya_and_books_codeforces.cpp
├── 51_eleven_codeforces.cpp
├── 52_codechef_flatland.cpp
├── 53_codeforces_MUH_and_sticks.cpp
├── 54_print_subset_of_size_k_of_array.cpp
├── 55_codechef_Easy_Fibonacci.cpp
├── 56_codechef_Chef_and_Interesting_Subsequences.cpp
├── 57_codechef_A-books.cpp
├── 58_codechef_phone_prices.cpp
├── 59_codechef_operations_on_a_matrix.cpp
├── 60_Adding_one_to_the_numbers.cpp
├── Chef and Price Control.cpp
├── Data Structures/
│   ├── Add a node at the Middle of linked list.cpp
│   ├── Add a node at the end of linked list.cpp
│   ├── Add a node at the front of linked list.cpp
│   ├── Array_in_data_structures.cpp
│   ├── Circular Linked List data_structure.cpp
│   ├── Delete a node of a linked list.cpp
│   ├── Doubly Linked list.cpp
│   ├── Find the middle of a given linked list.cpp
│   ├── Insert Node at the End of Doubly Linked List.cpp
│   ├── Insert Node in Middle of Doubly Linkedlist.cpp
│   ├── LinkedList_Code_Practice.cpp
│   ├── Vectors_in_STL_data_structure.cpp
│   ├── main.cpp
│   └── structure_in_c++.cpp
├── Kadane's_algorithm.cpp
├── Kadane's_algorithm.pptx
├── Lecture - 15.cpp
├── Lecture - 16.cpp
├── Lecture - 17.cpp
├── Lecture - 18.cpp
├── Lecture - 19.cpp
├── Lecture - 20.cpp
├── Lecture - 21.cpp
├── Lecture - 22.cpp
├── Lecture - 24.cpp
├── Lecture - 25.cpp
├── Lecture - 26.cpp
├── Lecture - 27.cpp
├── Lecture - 31.cpp
├── Lecture - 32.cpp
├── Lecture - 33.cpp
├── Lecture - 34.cpp
├── Leetcode/
│   ├── Add Digits.cpp
│   ├── Add Two Numbers Leetcode Solutions in Linkedlist.cpp
│   ├── Binary Search leetcode Solution.cpp
│   ├── Boolean Matrix.cpp
│   ├── Count the Number of Consistent Strings.cpp
│   ├── Graph/
│   │   ├── All Paths From Source to Target.cpp
│   │   ├── Course Schedule.cpp
│   │   ├── Detect cycle in a directed graph.cpp
│   │   ├── Find Eventual Safe States.cpp
│   │   ├── Find if Path Exists in Graph.cpp
│   │   ├── Find the Town Judge.cpp
│   │   ├── Flood Fill.cpp
│   │   ├── Keys and Rooms.cpp
│   │   ├── Max Area of Island.cpp
│   │   ├── Minimum Time to Collect All Apples in a Tree.cpp
│   │   ├── Number of Enclaves.cpp
│   │   ├── Number of Islands.cpp
│   │   ├── Number of Provinces.cpp
│   │   ├── Number of closed Islands.cpp
│   │   ├── Rotting Oranges.cpp
│   │   ├── Steps by Knight.cpp
│   │   ├── Surrounded Regions.cpp
│   │   ├── Time Needed to Inform All Employees.cpp
│   │   ├── Topological sort .cpp
│   │   └── Topological sort using dfs.cpp
│   ├── Hashing/
│   │   ├── Check if two arrays are equal or not.cpp
│   │   ├── Custom Sort String.cpp
│   │   ├── First Repeating Element.cpp
│   │   ├── Group Anagrams.cpp
│   │   ├── Intersection of two arrays.cpp
│   │   ├── Key Pair.cpp
│   │   ├── LFU Cache.cpp
│   │   ├── Non-Repeating Element.cpp
│   │   ├── Pairs with Positive Negative values.cpp
│   │   ├── Relative Sort Array.cpp
│   │   ├── Sort Array by Increasing Frequency.cpp
│   │   ├── Subarray with 0 sum.cpp
│   │   ├── Winner of an election.cpp
│   │   ├── unordered_map.cpp
│   │   └── unordered_set.cpp
│   ├── Interchanging the rows of a Matrix.cpp
│   ├── Majority Element Geeksforgeeks leetcode Moore's Voting Algorithm.cpp
│   ├── Median of Two sorted arrays.cpp
│   ├── Middle of the Linked List Leetcode.cpp
│   ├── Middle of the Linked List.cpp
│   ├── Move Zeroes.cpp
│   ├── Multiply two matrices.cpp
│   ├── Naive Pattern Search.cpp
│   ├── Next Greater Element.cpp
│   ├── Non Repeating Character.cpp
│   ├── Peak element.cpp
│   ├── Rearrange Array Alternately Geeksforgeeks.cpp
│   ├── Recursion/
│   │   ├── 0-1 Knapsack Problem Top down.cpp
│   │   ├── Best Time to Buy and Sell Stock.cpp
│   │   ├── Climbing Stairs.cpp
│   │   ├── Decode Ways.cpp
│   │   ├── Delete middle element of a stack.cpp
│   │   ├── Divisor Game.cpp
│   │   ├── Factorial.cpp
│   │   ├── Fibonacci Number.cpp
│   │   ├── House Robber.cpp
│   │   ├── Largest Element in Array.cpp
│   │   ├── Min Cost Climbing Stairs.cpp
│   │   ├── Nth Fibonacci Number.cpp
│   │   ├── Partition Equal Subset Sum.cpp
│   │   ├── Perfect Squares.cpp
│   │   ├── Perfect Sum Problem.cpp
│   │   ├── Power Of Numbers.cpp
│   │   ├── Print 1 To N Without Loop.cpp
│   │   ├── Reverse a String.cpp
│   │   ├── Subset Sum Problem.cpp
│   │   ├── Sum of Array.cpp
│   │   ├── Target Sum.cpp
│   │   └── Tower Of Hanoi.cpp
│   ├── Reverse Linked List.cpp
│   ├── Rotate Array Leetcode.cpp
│   ├── Rotate List.cpp
│   ├── Search in a row-column sorted Matrix.cpp
│   ├── Single Number Leetcode solution.cpp
│   ├── Sort Array By Parity.cpp
│   ├── Sort Colors.cpp
│   ├── Spirally traversing a matrix.cpp
│   ├── Square root.cpp
│   ├── Subarray sum equals K.cpp
│   ├── Trapping Rain Water.cpp
│   ├── Tree/
│   │   ├── Balanced Binary Tree.cpp
│   │   ├── Binary Tree Inorder Traversal.cpp
│   │   ├── Binary Tree Right Side View.cpp
│   │   ├── Binary Tree Zigzag Level Order Traversal.cpp
│   │   ├── Children Sum Parent.cpp
│   │   ├── Construct Binary Tree from Preorder and Inorder Traversal.cpp
│   │   ├── Diameter of Binary Tree.cpp
│   │   ├── Invert Binary Tree.cpp
│   │   ├── Level Order Traversal.cpp
│   │   ├── Lowest Common Ancestor of a Binary Tree.cpp
│   │   ├── Maximum Depth of Binary Tree.cpp
│   │   ├── Populating Next Right Pointers in Each Node.cpp
│   │   ├── Subtree of Another Tree.cpp
│   │   ├── Symmetric Tree.cpp
│   │   ├── Vertical Width of a Binary Tree .cpp
│   │   └── same Tree.cpp
│   ├── count 1's in binary array.cpp
│   ├── linked-list-cycle.cpp
│   ├── linkedlist/
│   │   ├── Copy List with Random Pointer.cpp
│   │   ├── Delete Node in a Linked List.cpp
│   │   ├── Intersection of Two Linked Lists.cpp
│   │   ├── Linked List Cycle II.cpp
│   │   ├── Merge Two Sorted Lists.cpp
│   │   ├── Palindrome Linked List.cpp
│   │   ├── Remove Duplicates from Sorted List.cpp
│   │   ├── Remove Nth Node From End of List.cpp
│   │   ├── Remove duplicates from an unsorted linked list.cpp
│   │   ├── Reverse Linked List.cpp
│   │   ├── Sort List.cpp
│   │   ├── Swap Nodes in Pairs.cpp
│   │   └── Swapping Nodes in a Linked List.cpp
│   ├── stack/
│   │   ├── Evaluate Reverse Polish Notation.cpp
│   │   ├── Implement Queue using Stacks.cpp
│   │   ├── Implement Stack using Queues.cpp
│   │   ├── Largest Rectangle in Histogram.cpp
│   │   ├── Min Stack.cpp
│   │   ├── Next Greater Element I.cpp
│   │   ├── Online Stock Span.cpp
│   │   ├── Remove All Adjacent Duplicates In String.cpp
│   │   ├── Remove All Adjacent Duplicates in String II.cpp
│   │   ├── Reverse First K elements of Queue.cpp
│   │   └── Valid Parentheses.cpp
│   ├── string/
│   │   ├── Find the Index of the First Occurrence in a String.cpp
│   │   ├── Gas Station.cpp
│   │   └── Maximum Ice Cream Bars.cpp
│   └── sum of numbers in string.cpp
├── README.md
├── STL/
│   ├── Array_Algorithms_in_stl.cpp
│   ├── Binary search in STL.cpp
│   ├── List_in_STL.cpp
│   ├── Queue_in_STL.cpp
│   ├── Vectors_Functions_in_STL.cpp
│   ├── What is STL.cpp
│   ├── deque_in_STL.cpp
│   ├── pair_in_STL.cpp
│   ├── priority Queue in STL.cpp
│   ├── sort_in_STL.cpp
│   └── stack in STL data structure.cpp
├── Templates_in_c++.cpp
├── Tree/
│   ├── Binary seacrh tree
│   ├── Binary_tree.cpp
│   ├── Code of Deletion of Node in BST.cpp
│   ├── Code of Inorder Traversal.cpp
│   ├── Insertion in BST.cpp
│   ├── code of Hashing in C++.cpp
│   └── code of preorer and Postorder traversal.cpp
├── chef and Icecream.cpp
├── chef and string.cpp
└── map_in_c++
Download .txt
SYMBOL INDEX (480 symbols across 204 files)

FILE: 35_hacker_two_strings.cpp
  function main (line 15) | int main()

FILE: 36_codechef_Encoding_message.cpp
  function main (line 15) | int main()

FILE: 37_codechef_spell_bob.cpp
  function main (line 15) | int main()

FILE: 38_codechef_fits_square_in_triangle.cpp
  function main (line 11) | int main()

FILE: 39_codechef_chef_and_Eid.cpp
  function main (line 14) | int main()

FILE: 40_codechef_chef_judges_competition.cpp
  function main (line 14) | int main()

FILE: 41_codechef_chef_and_glove.cpp
  function main (line 13) | int main()

FILE: 42_codechef_the_great_run.cpp
  function main (line 12) | int main()

FILE: 43_codechef_attendance.cpp
  function main (line 12) | int main()

FILE: 44_codechef_making_a_meal.cpp
  function main (line 14) | int main()

FILE: 45_codechef_uncle_johny.cpp
  function main (line 15) | int main()

FILE: 46_drink_codeforce.cpp
  function main (line 11) | int main()

FILE: 47_candles_codeforces.cpp
  function main (line 11) | int main()

FILE: 49_two_buttons_codeforces.cpp
  function main (line 14) | int main()

FILE: 50_vanya_and_books_codeforces.cpp
  function main (line 13) | int main()

FILE: 51_eleven_codeforces.cpp
  function main (line 15) | int main()

FILE: 52_codechef_flatland.cpp
  function main (line 12) | int main()

FILE: 53_codeforces_MUH_and_sticks.cpp
  function main (line 12) | int main()

FILE: 54_print_subset_of_size_k_of_array.cpp
  function main (line 15) | int main()

FILE: 55_codechef_Easy_Fibonacci.cpp
  function main (line 13) | int main()

FILE: 56_codechef_Chef_and_Interesting_Subsequences.cpp
  function ll (line 16) | ll int gcd(ll int a, ll int b)
  function nCr (line 23) | void nCr(int n, int r)
  function main (line 63) | int main()

FILE: 57_codechef_A-books.cpp
  function main (line 11) | int main()

FILE: 58_codechef_phone_prices.cpp
  function main (line 14) | int main()

FILE: 59_codechef_operations_on_a_matrix.cpp
  function main (line 18) | int main()

FILE: 60_Adding_one_to_the_numbers.cpp
  function main (line 13) | int main(){

FILE: Chef and Price Control.cpp
  function main (line 13) | int main(){

FILE: Data Structures/Add a node at the Middle of linked list.cpp
  type node (line 16) | struct node{
  function printList (line 22) | void printList (node *n){
  function push (line 34) | void push(node **head_ref , int newData){
  function insertAfter (line 43) | void insertAfter(node *prev_node , int newData){
  function main (line 50) | int main(){

FILE: Data Structures/Add a node at the end of linked list.cpp
  type node (line 16) | struct node{
  function printList (line 22) | void printList (node *n){
  function push (line 34) | void push(node **head_ref , int newData){
  function insertAfter (line 43) | void insertAfter(node *prev_node , int newData){
  function append (line 53) | void append(node **head_ref, int newData){
  function main (line 75) | int main(){

FILE: Data Structures/Add a node at the front of linked list.cpp
  type node (line 16) | struct node{
  function printList (line 22) | void printList (node *n){
  function push (line 40) | void push(node **head_ref , int newData){
  function main (line 47) | int main(){

FILE: Data Structures/Array_in_data_structures.cpp
  function main (line 11) | int main(){

FILE: Data Structures/Circular Linked List data_structure.cpp
  type node (line 16) | struct node{
  function printList (line 21) | void printList (node *n){
  function printCircularList (line 31) | void printCircularList(node * first){
  function main (line 45) | int main(){

FILE: Data Structures/Delete a node of a linked list.cpp
  type node (line 15) | struct node{
  function printList (line 21) | void printList (node *n){
  function push (line 33) | void push(node **head_ref , int newData){
  function deleteNode (line 43) | void deleteNode(node **head_ref , int key){
  function main (line 74) | int main(){

FILE: Data Structures/Doubly Linked list.cpp
  type node (line 15) | struct node{
  function printList (line 23) | void printList (node *n){
  function push (line 35) | void push(node **head_ref, int new_data){
  function main (line 50) | int main(){

FILE: Data Structures/Find the middle of a given linked list.cpp
  type node (line 16) | struct node{
  function printList (line 21) | void printList (node *n){
  function printMiddleElement (line 32) | void printMiddleElement( node *head){
  function main (line 46) | int main(){

FILE: Data Structures/Insert Node at the End of Doubly Linked List.cpp
  type node (line 15) | struct node{
  function printList (line 23) | void printList (node *n){
  function push (line 35) | void push(node **head_ref, int new_data){
  function insertAfter (line 51) | void insertAfter(node *prev_node, int new_data){
  function append (line 72) | void append(node **head_ref, int new_data){
  function main (line 95) | int main(){

FILE: Data Structures/Insert Node in Middle of Doubly Linkedlist.cpp
  type node (line 15) | struct node{
  function printList (line 23) | void printList (node *n){
  function push (line 35) | void push(node **head_ref, int new_data){
  function insertAfter (line 51) | void insertAfter(node *prev_node, int new_data){
  function main (line 70) | int main(){

FILE: Data Structures/LinkedList_Code_Practice.cpp
  type node (line 16) | struct node{
  function printList (line 21) | void printList (node *n){
  function main (line 28) | int main(){

FILE: Data Structures/Vectors_in_STL_data_structure.cpp
  function main (line 14) | int main(){

FILE: Data Structures/structure_in_c++.cpp
  type student (line 11) | struct student{
    method studentDetails (line 17) | void studentDetails(){
  function main (line 24) | int main(){

FILE: Kadane's_algorithm.cpp
  function main (line 13) | int main(){

FILE: Lecture - 15.cpp
  function main (line 13) | int main()

FILE: Lecture - 16.cpp
  function main (line 12) | int main()

FILE: Lecture - 17.cpp
  function main (line 11) | int main()

FILE: Lecture - 18.cpp
  function main (line 3) | int main()

FILE: Lecture - 19.cpp
  function main (line 5) | int main()

FILE: Lecture - 20.cpp
  function main (line 4) | int main()

FILE: Lecture - 21.cpp
  function main (line 4) | int main()

FILE: Lecture - 22.cpp
  function main (line 5) | int main()

FILE: Lecture - 24.cpp
  function seive (line 13) | void seive( int n)
  function main (line 38) | int main()

FILE: Lecture - 25.cpp
  function gcd (line 12) | int gcd(int a, int b)
  function main (line 20) | int main()

FILE: Lecture - 26.cpp
  function main (line 11) | int main()

FILE: Lecture - 27.cpp
  function main (line 11) | int main()

FILE: Lecture - 31.cpp
  function main (line 11) | int main()

FILE: Lecture - 32.cpp
  function main (line 11) | int main()

FILE: Lecture - 33.cpp
  function main (line 11) | int main()

FILE: Lecture - 34.cpp
  function main (line 11) | int main()

FILE: Leetcode/Add Digits.cpp
  class Solution (line 4) | class Solution {
    method addDigitsHelper (line 7) | int addDigitsHelper(int num){
    method addDigits (line 17) | int addDigits(int num) {

FILE: Leetcode/Add Two Numbers Leetcode Solutions in Linkedlist.cpp
  class Solution (line 14) | class Solution {
    method ListNode (line 16) | ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) {

FILE: Leetcode/Binary Search leetcode Solution.cpp
  class Solution (line 4) | class Solution {
    method search (line 6) | int search(vector<int>& nums, int target) {

FILE: Leetcode/Boolean Matrix.cpp
  function booleanMatrix (line 3) | void booleanMatrix(vector<vector<int> > &matrix)

FILE: Leetcode/Count the Number of Consistent Strings.cpp
  class Solution (line 3) | class Solution {
    method countConsistentStrings (line 5) | int countConsistentStrings(string allowed, vector<string>& words) {

FILE: Leetcode/Graph/All Paths From Source to Target.cpp
  class Solution (line 3) | class Solution {
    method dfs (line 6) | void dfs(vector<vector<int>>& graph, vector<vector<int>>& ans, vector<...
    method allPathsSourceTarget (line 22) | vector<vector<int>> allPathsSourceTarget(vector<vector<int>>& graph) {

FILE: Leetcode/Graph/Course Schedule.cpp
  class Solution (line 3) | class Solution {
    method DFSRec (line 6) | bool DFSRec(int s, vector<bool>&visited, vector<bool>&currVisited, vec...
    method canFinish (line 26) | bool canFinish(int numCourses, vector<vector<int>>& prerequisites) {

FILE: Leetcode/Graph/Detect cycle in a directed graph.cpp
  class Solution (line 3) | class Solution {
    method cycle (line 7) | bool cycle(int s, vector<bool>&visited, vector<bool>&currVisited, vect...
    method isCyclic (line 25) | bool isCyclic(int V, vector<int> adj[]) {

FILE: Leetcode/Graph/Find Eventual Safe States.cpp
  class Solution (line 3) | class Solution {
    method DFSRec (line 6) | bool DFSRec(int s, vector<bool>&visited, vector<bool>&dfsVisited, vect...
    method eventualSafeNodes (line 26) | vector<int> eventualSafeNodes(vector<vector<int>>& graph) {

FILE: Leetcode/Graph/Find if Path Exists in Graph.cpp
  class Solution (line 3) | class Solution {
    method validPath (line 5) | bool validPath(int n, vector<vector<int>>& edges, int start, int end) {

FILE: Leetcode/Graph/Find the Town Judge.cpp
  class Solution (line 3) | class Solution {
    method findJudge (line 5) | int findJudge(int n, vector<vector<int>>& trust) {

FILE: Leetcode/Graph/Flood Fill.cpp
  class Solution (line 3) | class Solution {
    method isValid (line 6) | bool isValid(vector<vector<int>>& image, int i, int j, int n, int m , ...
    method floodFillRec (line 14) | void floodFillRec(vector<vector<int>>& image, int i, int j, int n, int...
    method floodFill (line 31) | vector<vector<int>> floodFill(vector<vector<int>>& image, int sr, int ...

FILE: Leetcode/Graph/Keys and Rooms.cpp
  class Solution (line 3) | class Solution {
    method canVisitAllRooms (line 5) | bool canVisitAllRooms(vector<vector<int>>& rooms) {

FILE: Leetcode/Graph/Max Area of Island.cpp
  class Solution (line 3) | class Solution {
    method isValid (line 6) | bool isValid(int i, int j, int n, int m, vector<vector<int>>& grid){
    method dfs (line 13) | void dfs(vector<vector<int>>& grid, int i, int j, int n, int m, int &a...
    method maxAreaOfIsland (line 31) | int maxAreaOfIsland(vector<vector<int>>& grid) {

FILE: Leetcode/Graph/Minimum Time to Collect All Apples in a Tree.cpp
  class Solution (line 3) | class Solution {
    method dfs (line 6) | int dfs(vector<vector<int>>&adj, int node, int mycost, vector<bool>& h...
    method minTime (line 17) | int minTime(int n, vector<vector<int>>& edges, vector<bool>& hasApple) {

FILE: Leetcode/Graph/Number of Enclaves.cpp
  class Solution (line 3) | class Solution {
    method count (line 6) | int count(vector<vector<int>>& grid){
    method isValid (line 21) | bool isValid(int i, int j, int n, int m, vector<vector<int>>& grid){
    method dfs (line 28) | void dfs(int i, int j, int n, int m, vector<vector<int>>& grid){
    method numEnclaves (line 44) | int numEnclaves(vector<vector<int>>& grid) {

FILE: Leetcode/Graph/Number of Islands.cpp
  class Solution (line 3) | class Solution {
    method isValid (line 7) | bool isValid(int i, int j, int n , int m, vector<vector<char>>& grid){
    method numIslandsRec (line 14) | void numIslandsRec(int i, int j, int n , int m, vector<vector<char>>& ...
    method numIslands (line 32) | int numIslands(vector<vector<char>>& grid) {

FILE: Leetcode/Graph/Number of Provinces.cpp
  class Solution (line 3) | class Solution {
    method dfs (line 6) | void dfs(int s, int n, vector<vector<int>>& isConnected, vector<bool>&...
    method findCircleNum (line 30) | int findCircleNum(vector<vector<int>>& isConnected) {

FILE: Leetcode/Graph/Number of closed Islands.cpp
  class Solution (line 3) | class Solution {
    method isValid (line 7) | bool isValid(int i, int j, int n, int m ,vector<vector<int>>& grid){
    method dfs (line 14) | void dfs(int i, int j, int n, int m ,vector<vector<int>>& grid){
    method closedIsland (line 30) | int closedIsland(vector<vector<int>>& grid) {

FILE: Leetcode/Graph/Rotting Oranges.cpp
  class Solution (line 3) | class Solution {
    method isValid (line 7) | bool isValid(int i, int j, int n, int m, vector<vector<int>>& grid){
    method orangesRotting (line 14) | int orangesRotting(vector<vector<int>>& grid) {

FILE: Leetcode/Graph/Steps by Knight.cpp
  class Solution (line 3) | class Solution
    method isValid (line 8) | bool isValid(int i, int j, int n, vector<vector<bool>>&visited){
    method minStepToReachTarget (line 15) | int minStepToReachTarget(vector<int>&KnightPos,vector<int>&TargetPos,i...

FILE: Leetcode/Graph/Surrounded Regions.cpp
  class Solution (line 3) | class Solution {
    method convert (line 6) | void convert(vector<vector<char>>& board){
    method isValid (line 22) | bool isValid(int i , int j, int n, int m, vector<vector<char>>& board){
    method dfs (line 29) | void dfs(vector<vector<char>>& board, int i , int j, int n, int m){
    method solve (line 46) | void solve(vector<vector<char>>& board) {

FILE: Leetcode/Graph/Time Needed to Inform All Employees.cpp
  class Solution (line 4) | class Solution {
    method dfs (line 10) | void dfs(int manager, vector<int>& informTime){
    method numOfMinutes (line 22) | int numOfMinutes(int n, int headID, vector<int>& manager, vector<int>&...

FILE: Leetcode/Graph/Topological sort .cpp
  class Solution (line 3) | class Solution
    method topoSort (line 7) | vector<int> topoSort(int V, vector<int> adj[])

FILE: Leetcode/Graph/Topological sort using dfs.cpp
  class Solution (line 7) | class Solution
    method DFSRec (line 12) | void DFSRec(int s, stack<int>&st, vector<bool>&visited, vector<int> ad...
    method topoSort (line 25) | vector<int> topoSort(int V, vector<int> adj[])

FILE: Leetcode/Hashing/Check if two arrays are equal or not.cpp
  class Solution (line 3) | class Solution{
    method check (line 7) | bool check(vector<ll> A, vector<ll> B, int n) {

FILE: Leetcode/Hashing/Custom Sort String.cpp
  class Solution (line 3) | class Solution {
    method string (line 5) | string customSortString(string order, string str) {

FILE: Leetcode/Hashing/First Repeating Element.cpp
  class Solution (line 3) | class Solution{
    method firstRepeated (line 6) | int firstRepeated(int arr[], int n) {

FILE: Leetcode/Hashing/Group Anagrams.cpp
  class Solution (line 3) | class Solution {
    method groupAnagrams (line 5) | vector<vector<string>> groupAnagrams(vector<string>& strs) {

FILE: Leetcode/Hashing/Intersection of two arrays.cpp
  function NumberofElementsInIntersection (line 3) | int NumberofElementsInIntersection (int a[], int b[], int n, int m )

FILE: Leetcode/Hashing/Key Pair.cpp
  class Solution (line 3) | class Solution{
    method hasArrayTwoCandidates (line 7) | bool hasArrayTwoCandidates(int arr[], int n, int x) {

FILE: Leetcode/Hashing/LFU Cache.cpp
  class LFUCache (line 3) | class LFUCache {
    method updateFreq (line 10) | void updateFreq(int key){
    method LFUCache (line 32) | LFUCache(int capacity) {
    method get (line 36) | int get(int key) {
    method put (line 44) | void put(int key, int value) {

FILE: Leetcode/Hashing/Non-Repeating Element.cpp
  class Solution (line 4) | class Solution{
    method firstNonRepeating (line 6) | int firstNonRepeating(int arr[], int n)

FILE: Leetcode/Hashing/Pairs with Positive Negative values.cpp
  class Solution (line 4) | class Solution{
    method PosNegPair (line 6) | vector<int> PosNegPair(int a[], int n) {

FILE: Leetcode/Hashing/Relative Sort Array.cpp
  class Solution (line 3) | class Solution {
    method relativeSortArray (line 5) | vector<int> relativeSortArray(vector<int>& arr1, vector<int>& arr2) {

FILE: Leetcode/Hashing/Sort Array by Increasing Frequency.cpp
  class Solution (line 3) | class Solution {
    method frequencySort (line 5) | vector<int> frequencySort(vector<int>& nums) {

FILE: Leetcode/Hashing/Subarray with 0 sum.cpp
  class Solution (line 3) | class Solution{
    method subArrayExists (line 7) | bool subArrayExists(int arr[], int n)

FILE: Leetcode/Hashing/Winner of an election.cpp
  class Solution (line 3) | class Solution{
    method winner (line 7) | vector<string> winner(string arr[],int n)

FILE: Leetcode/Hashing/unordered_map.cpp
  function main (line 5) | int main(){

FILE: Leetcode/Hashing/unordered_set.cpp
  function main (line 5) | int main(){

FILE: Leetcode/Interchanging the rows of a Matrix.cpp
  function interchangeRows (line 4) | void interchangeRows(vector<vector<int> > &matrix)

FILE: Leetcode/Majority Element Geeksforgeeks leetcode Moore's Voting Algorithm.cpp
  function majorityElement (line 8) | int majorityElement(int arr[], int n)
  function main (line 36) | int main(){

FILE: Leetcode/Median of Two sorted arrays.cpp
  function findMedian (line 6) | int findMedian(int arr[], int n, int brr[], int m){

FILE: Leetcode/Middle of the Linked List Leetcode.cpp
  class Solution (line 14) | class Solution {
    method size (line 17) | int size(ListNode* head){
    method ListNode (line 26) | ListNode* middleNode(ListNode* head) {

FILE: Leetcode/Middle of the Linked List.cpp
  class Solution (line 11) | class Solution {
    method ListNode (line 13) | ListNode* middleNode(ListNode* head) {

FILE: Leetcode/Move Zeroes.cpp
  class Solution (line 3) | class Solution {
    method moveZeroes (line 5) | void moveZeroes(vector<int>& nums) {

FILE: Leetcode/Multiply two matrices.cpp
  function multiplyMatrix (line 3) | vector<vector<int> > multiplyMatrix( const vector<vector<int> >& A, cons...

FILE: Leetcode/Non Repeating Character.cpp
  function nonrepeatingCharacter (line 2) | char nonrepeatingCharacter(string s)

FILE: Leetcode/Peak element.cpp
  function peakElement (line 3) | int peakElement(int arr[], int n)

FILE: Leetcode/Rearrange Array Alternately Geeksforgeeks.cpp
  function rearrange (line 6) | void rearrange(long long int arr[], int n){
  function main (line 26) | int main()

FILE: Leetcode/Recursion/0-1 Knapsack Problem Top down.cpp
  class Solution (line 3) | class Solution
    method knapSack (line 7) | int knapSack(int W, int wt[], int val[], int n)

FILE: Leetcode/Recursion/Best Time to Buy and Sell Stock.cpp
  class Solution (line 3) | class Solution {
    method maxProfit (line 5) | int maxProfit(vector<int>& prices) {

FILE: Leetcode/Recursion/Climbing Stairs.cpp
  class Solution (line 4) | class Solution {
    method climbStairs (line 6) | int climbStairs(int n) {

FILE: Leetcode/Recursion/Decode Ways.cpp
  class Solution (line 4) | class Solution {
    method numDecodingsHelper (line 7) | int numDecodingsHelper(string s, int pos){
    method numDecodings (line 19) | int numDecodings(string s) {

FILE: Leetcode/Recursion/Delete middle element of a stack.cpp
  class Solution (line 3) | class Solution
    method deleteMidHelper (line 8) | void deleteMidHelper(stack<int>&st, int count, int &pos){
    method deleteMid (line 18) | void deleteMid(stack<int>&s, int sizeOfStack)

FILE: Leetcode/Recursion/Divisor Game.cpp
  class Solution (line 3) | class Solution {
    method divisorGame (line 5) | bool divisorGame(int n) {

FILE: Leetcode/Recursion/Factorial.cpp
  class Solution (line 3) | class Solution{
    method factorial (line 5) | long long int factorial(int N){

FILE: Leetcode/Recursion/Fibonacci Number.cpp
  class Solution (line 3) | class Solution {
    method fib (line 5) | int fib(int n) {

FILE: Leetcode/Recursion/House Robber.cpp
  class Solution (line 4) | class Solution {
    method fun (line 6) | int fun(vector<int>& nums, int n){
    method rob (line 14) | int rob(vector<int>& nums) {

FILE: Leetcode/Recursion/Largest Element in Array.cpp
  class Solution (line 3) | class Solution
    method largest (line 6) | int largest(vector<int> &arr, int n)

FILE: Leetcode/Recursion/Min Cost Climbing Stairs.cpp
  class Solution (line 4) | class Solution {
    method minCost (line 7) | int minCost(vector<int>& cost, int n){
    method minCostClimbingStairs (line 14) | int minCostClimbingStairs(vector<int>& cost) {

FILE: Leetcode/Recursion/Nth Fibonacci Number.cpp
  class Solution (line 4) | class Solution {
    method nthFibonacci (line 7) | long long int nthFibonacci(long long int n){

FILE: Leetcode/Recursion/Partition Equal Subset Sum.cpp
  class Solution (line 6) | class Solution {
    method subsetSum (line 9) | bool subsetSum(vector<int>& nums, int n, int sum){
    method canPartition (line 18) | bool canPartition(vector<int>& nums) {
    method subsetSum (line 38) | bool subsetSum(vector<int>& nums, int n, int sum, vector<vector<int>>&...
    method canPartition (line 46) | bool canPartition(vector<int>& nums) {
    method canPartition (line 73) | bool canPartition(vector<int>& nums) {
  class Solution (line 35) | class Solution {
    method subsetSum (line 9) | bool subsetSum(vector<int>& nums, int n, int sum){
    method canPartition (line 18) | bool canPartition(vector<int>& nums) {
    method subsetSum (line 38) | bool subsetSum(vector<int>& nums, int n, int sum, vector<vector<int>>&...
    method canPartition (line 46) | bool canPartition(vector<int>& nums) {
    method canPartition (line 73) | bool canPartition(vector<int>& nums) {
  class Solution (line 71) | class Solution {
    method subsetSum (line 9) | bool subsetSum(vector<int>& nums, int n, int sum){
    method canPartition (line 18) | bool canPartition(vector<int>& nums) {
    method subsetSum (line 38) | bool subsetSum(vector<int>& nums, int n, int sum, vector<vector<int>>&...
    method canPartition (line 46) | bool canPartition(vector<int>& nums) {
    method canPartition (line 73) | bool canPartition(vector<int>& nums) {

FILE: Leetcode/Recursion/Perfect Squares.cpp
  class Solution (line 4) | class Solution {
    method solve (line 6) | int solve(int n){
    method numSquares (line 18) | int numSquares(int n) {

FILE: Leetcode/Recursion/Perfect Sum Problem.cpp
  class Solution (line 7) | class Solution{
    method countSubset (line 11) | int countSubset(int arr[], int n, int sum){
    method perfectSum (line 29) | int perfectSum(int arr[], int n, int sum)
    method countSubset (line 45) | int countSubset(int arr[], int n, int sum, vector<vector<int>>&dp){
    method perfectSum (line 66) | int perfectSum(int arr[], int n, int sum)
  class Solution (line 41) | class Solution{
    method countSubset (line 11) | int countSubset(int arr[], int n, int sum){
    method perfectSum (line 29) | int perfectSum(int arr[], int n, int sum)
    method countSubset (line 45) | int countSubset(int arr[], int n, int sum, vector<vector<int>>&dp){
    method perfectSum (line 66) | int perfectSum(int arr[], int n, int sum)

FILE: Leetcode/Recursion/Power Of Numbers.cpp
  class Solution (line 3) | class Solution{
    method power (line 7) | long long power(int N,int R)

FILE: Leetcode/Recursion/Print 1 To N Without Loop.cpp
  class Solution (line 3) | class Solution{
    method printNos (line 6) | void printNos(int N)

FILE: Leetcode/Recursion/Reverse a String.cpp
  function string (line 3) | string reverseWord(string str){

FILE: Leetcode/Recursion/Subset Sum Problem.cpp
  class Solution (line 6) | class Solution{
    method subsetSum (line 8) | bool subsetSum(vector<int>arr, int n, int sum){
    method isSubsetSum (line 17) | bool isSubsetSum(vector<int>arr, int sum){
    method subsetSum (line 29) | bool subsetSum(vector<int>arr, int n, int sum, vector<vector<int>>&dp){
    method isSubsetSum (line 37) | bool isSubsetSum(vector<int>arr, int sum){
  class Solution (line 27) | class Solution{
    method subsetSum (line 8) | bool subsetSum(vector<int>arr, int n, int sum){
    method isSubsetSum (line 17) | bool isSubsetSum(vector<int>arr, int sum){
    method subsetSum (line 29) | bool subsetSum(vector<int>arr, int n, int sum, vector<vector<int>>&dp){
    method isSubsetSum (line 37) | bool isSubsetSum(vector<int>arr, int sum){

FILE: Leetcode/Recursion/Sum of Array.cpp
  class Solution (line 3) | class Solution{
    method sum (line 7) | int sum(int arr[], int n) {

FILE: Leetcode/Recursion/Target Sum.cpp
  class Solution (line 3) | class Solution {
    method countSubset (line 6) | int countSubset(vector<int>& nums, int n, int sum, vector<vector<int>>...
    method findTargetSumWays (line 26) | int findTargetSumWays(vector<int>& nums, int target) {

FILE: Leetcode/Recursion/Tower Of Hanoi.cpp
  class Solution (line 3) | class Solution{
    method TOHHelper (line 9) | void TOHHelper(int N, int from, int to, int aux){
    method toh (line 17) | long long toh(int N, int from, int to, int aux) {

FILE: Leetcode/Reverse Linked List.cpp
  class Solution (line 13) | class Solution {
    method ListNode (line 15) | ListNode* reverseList(ListNode* head) {

FILE: Leetcode/Rotate Array Leetcode.cpp
  class Solution (line 1) | class Solution {
    method reverse (line 4) | void reverse(vector<int> &num, int low, int high){
    method rotate (line 11) | void rotate(vector<int>& nums, int k) {

FILE: Leetcode/Rotate List.cpp
  class Solution (line 14) | class Solution {
    method size (line 17) | int size(ListNode* head){
    method ListNode (line 26) | ListNode* rotateRight(ListNode* head, int k) {

FILE: Leetcode/Search in a row-column sorted Matrix.cpp
  function search (line 5) | bool search(vector<vector<int> > matrix, int n, int m, int x)

FILE: Leetcode/Single Number Leetcode solution.cpp
  class Solution (line 5) | class Solution {
    method singleNumber (line 7) | int singleNumber(vector<int>& nums) {

FILE: Leetcode/Sort Array By Parity.cpp
  class Solution (line 1) | class Solution {
    method sortArrayByParity (line 3) | vector<int> sortArrayByParity(vector<int>& A) {

FILE: Leetcode/Sort Colors.cpp
  class Solution (line 8) | class Solution {
    method sortColors (line 10) | void sortColors(vector<int>& nums) {

FILE: Leetcode/Spirally traversing a matrix.cpp
  class Solution (line 3) | class Solution
    method spirallyTraverse (line 6) | vector<int> spirallyTraverse(vector<vector<int> > matrix, int r, int c)

FILE: Leetcode/Square root.cpp
  function floorSqrt (line 13) | long long int floorSqrt(long long int x)
  function main (line 39) | int main()

FILE: Leetcode/Subarray sum equals K.cpp
  class Solution (line 1) | class Solution {
    method subarraySum (line 3) | int subarraySum(vector<int>& nums, int k) {

FILE: Leetcode/Trapping Rain Water.cpp
  function trappingWater (line 7) | int trappingWater(int arr[], int n){
  function main (line 32) | int main(){

FILE: Leetcode/Tree/Balanced Binary Tree.cpp
  class Solution (line 14) | class Solution {
    method height (line 17) | int height(TreeNode* root){
    method inorderUtil (line 24) | void inorderUtil(TreeNode* root, bool & ans){
    method isBalanced (line 38) | bool isBalanced(TreeNode* root) {

FILE: Leetcode/Tree/Binary Tree Inorder Traversal.cpp
  class Solution (line 15) | class Solution {
    method preorder (line 18) | void preorder(TreeNode* root, vector<int>  &ans){
    method inorderTraversal (line 26) | vector<int> inorderTraversal(TreeNode* root) {

FILE: Leetcode/Tree/Binary Tree Right Side View.cpp
  class Solution (line 14) | class Solution {
    method rightSideView (line 16) | vector<int> rightSideView(TreeNode* root) {

FILE: Leetcode/Tree/Binary Tree Zigzag Level Order Traversal.cpp
  function zigzagLevelOrder (line 3) | vector<vector<int>> zigzagLevelOrder(TreeNode* root) {

FILE: Leetcode/Tree/Children Sum Parent.cpp
  function isSumProperty (line 3) | int isSumProperty(Node *root)

FILE: Leetcode/Tree/Construct Binary Tree from Preorder and Inorder Traversal.cpp
  class Solution (line 14) | class Solution {
    method TreeNode (line 19) | TreeNode* buildTreeUtil(vector<int>& preorder, vector<int>& inorder, i...
    method TreeNode (line 42) | TreeNode* buildTree(vector<int>& preorder, vector<int>& inorder) {

FILE: Leetcode/Tree/Diameter of Binary Tree.cpp
  class Solution (line 14) | class Solution {
    method height (line 19) | int height(TreeNode* root){
    method diameterOfBinaryTree (line 32) | int diameterOfBinaryTree(TreeNode* root) {

FILE: Leetcode/Tree/Invert Binary Tree.cpp
  class Solution (line 14) | class Solution {
    method TreeNode (line 16) | TreeNode* invertTree(TreeNode* root) {

FILE: Leetcode/Tree/Level Order Traversal.cpp
  function levelOrder (line 3) | vector<vector<int>> levelOrder(TreeNode* root) {

FILE: Leetcode/Tree/Lowest Common Ancestor of a Binary Tree.cpp
  class Solution (line 16) | class Solution {
    method findPath (line 19) | bool findPath(TreeNode* root,  vector<TreeNode*> &path, TreeNode* n){
    method TreeNode (line 33) | TreeNode* lowestCommonAncestor(TreeNode* root, TreeNode* p, TreeNode* ...
    method TreeNode (line 71) | TreeNode* lowestCommonAncestor(TreeNode* root, TreeNode* p, TreeNode* ...
  class Solution (line 67) | class Solution {
    method findPath (line 19) | bool findPath(TreeNode* root,  vector<TreeNode*> &path, TreeNode* n){
    method TreeNode (line 33) | TreeNode* lowestCommonAncestor(TreeNode* root, TreeNode* p, TreeNode* ...
    method TreeNode (line 71) | TreeNode* lowestCommonAncestor(TreeNode* root, TreeNode* p, TreeNode* ...

FILE: Leetcode/Tree/Maximum Depth of Binary Tree.cpp
  class Solution (line 3) | class Solution {
    method maxDepth (line 5) | int maxDepth(TreeNode* root) {

FILE: Leetcode/Tree/Populating Next Right Pointers in Each Node.cpp
  class Solution (line 21) | class Solution {
    method Node (line 23) | Node* connect(Node* root) {

FILE: Leetcode/Tree/Subtree of Another Tree.cpp
  class Solution (line 14) | class Solution {
    method match (line 20) | bool match(TreeNode* root, TreeNode* subRoot){
    method inorder (line 38) | void inorder(TreeNode* root, TreeNode* subRoot){
    method isSubtree (line 49) | bool isSubtree(TreeNode* root, TreeNode* subRoot) {

FILE: Leetcode/Tree/Symmetric Tree.cpp
  class Solution (line 14) | class Solution {
    method match (line 17) | bool match(TreeNode* root1, TreeNode* root2){
    method isSymmetric (line 34) | bool isSymmetric(TreeNode* root) {

FILE: Leetcode/Tree/Vertical Width of a Binary Tree .cpp
  function inorderUtil (line 21) | void inorderUtil(Node* root, int hd){
  function verticalWidth (line 30) | int verticalWidth(Node* root)

FILE: Leetcode/Tree/same Tree.cpp
  class Solution (line 15) | class Solution {
    method inorder (line 18) | void inorder(TreeNode* root, vector<int>&v){
    method preorder (line 27) | void preorder(TreeNode* root, vector<int>&v){
    method isSameTree (line 36) | bool isSameTree(TreeNode* p, TreeNode* q) {
    method isSameTree (line 58) | bool isSameTree(TreeNode* p, TreeNode* q) {
  class Solution (line 56) | class Solution {
    method inorder (line 18) | void inorder(TreeNode* root, vector<int>&v){
    method preorder (line 27) | void preorder(TreeNode* root, vector<int>&v){
    method isSameTree (line 36) | bool isSameTree(TreeNode* p, TreeNode* q) {
    method isSameTree (line 58) | bool isSameTree(TreeNode* p, TreeNode* q) {

FILE: Leetcode/count 1's in binary array.cpp
  function countOnes (line 11) | int countOnes(int arr[], int N)
  function main (line 39) | int main()

FILE: Leetcode/linked-list-cycle.cpp
  class Solution (line 12) | class Solution {
    method hasCycle (line 14) | bool hasCycle(ListNode *head) {

FILE: Leetcode/linkedlist/Copy List with Random Pointer.cpp
  class Solution (line 20) | class Solution {
    method Node (line 22) | Node* copyRandomList(Node* head) {

FILE: Leetcode/linkedlist/Delete Node in a Linked List.cpp
  class Solution (line 3) | class Solution {
    method deleteNode (line 5) | void deleteNode(ListNode* node) {

FILE: Leetcode/linkedlist/Intersection of Two Linked Lists.cpp
  class Solution (line 11) | class Solution {
    method ListNode (line 13) | ListNode *getIntersectionNode(ListNode *headA, ListNode *headB) {

FILE: Leetcode/linkedlist/Linked List Cycle II.cpp
  class Solution (line 11) | class Solution {
    method ListNode (line 13) | ListNode *detectCycle(ListNode *head) {

FILE: Leetcode/linkedlist/Merge Two Sorted Lists.cpp
  class Solution (line 13) | class Solution {
    method ListNode (line 15) | ListNode* mergeTwoLists(ListNode* list1, ListNode* list2) {

FILE: Leetcode/linkedlist/Palindrome Linked List.cpp
  class Solution (line 13) | class Solution {
    method isPalindrome (line 15) | bool isPalindrome(ListNode* head) {

FILE: Leetcode/linkedlist/Remove Duplicates from Sorted List.cpp
  class Solution (line 3) | class Solution {
    method ListNode (line 5) | ListNode* deleteDuplicates(ListNode* head) {

FILE: Leetcode/linkedlist/Remove Nth Node From End of List.cpp
  class Solution (line 13) | class Solution {
    method ListNode (line 15) | ListNode* removeNthFromEnd(ListNode* head, int n) {

FILE: Leetcode/linkedlist/Remove duplicates from an unsorted linked list.cpp
  class Solution (line 17) | class Solution
    method Node (line 21) | Node * removeDuplicates( Node *head)

FILE: Leetcode/linkedlist/Reverse Linked List.cpp
  class Solution (line 13) | class Solution {
    method ListNode (line 15) | ListNode* reverseList(ListNode* head) {

FILE: Leetcode/linkedlist/Sort List.cpp
  class Solution (line 13) | class Solution {
    method ListNode (line 16) | ListNode* Mid(ListNode* head){
    method ListNode (line 27) | ListNode* mergeSortedList(ListNode *p1, ListNode *p2){
    method ListNode (line 52) | ListNode* sortList(ListNode* head) {

FILE: Leetcode/linkedlist/Swap Nodes in Pairs.cpp
  class Solution (line 13) | class Solution {
    method ListNode (line 15) | ListNode* swapPairs(ListNode* head) {

FILE: Leetcode/linkedlist/Swapping Nodes in a Linked List.cpp
  class Solution (line 13) | class Solution {
    method ListNode (line 15) | ListNode* swapNodes(ListNode* head, int k) {

FILE: Leetcode/stack/Evaluate Reverse Polish Notation.cpp
  class Solution (line 3) | class Solution {
    method evalRPN (line 5) | int evalRPN(vector<string>& tokens) {

FILE: Leetcode/stack/Implement Queue using Stacks.cpp
  class MyQueue (line 3) | class MyQueue {
    method MyQueue (line 9) | MyQueue() {
    method push (line 13) | void push(int x) {
    method pop (line 17) | int pop() {
    method peek (line 23) | int peek() {
    method empty (line 34) | bool empty() {

FILE: Leetcode/stack/Implement Stack using Queues.cpp
  class MyStack (line 3) | class MyStack {
    method MyStack (line 8) | MyStack() {
    method push (line 12) | void push(int x) {
    method pop (line 25) | int pop() {
    method top (line 32) | int top() {
    method empty (line 36) | bool empty() {

FILE: Leetcode/stack/Largest Rectangle in Histogram.cpp
  class Solution (line 3) | class Solution {
    method previous_smaller (line 6) | vector<int> previous_smaller(vector<int>& heights){
    method next_smaller (line 22) | vector<int> next_smaller(vector<int>& heights){
    method largestRectangleArea (line 39) | int largestRectangleArea(vector<int>& heights) {

FILE: Leetcode/stack/Min Stack.cpp
  class MinStack (line 3) | class MinStack {
    method MinStack (line 7) | MinStack() {
    method push (line 11) | void push(int val) {
    method pop (line 19) | void pop() {
    method top (line 28) | int top() {
    method getMin (line 32) | int getMin() {

FILE: Leetcode/stack/Next Greater Element I.cpp
  class Solution (line 3) | class Solution {
    method nextGreaterElement (line 5) | vector<int> nextGreaterElement(vector<int>& nums1, vector<int>& nums2) {

FILE: Leetcode/stack/Online Stock Span.cpp
  class StockSpanner (line 3) | class StockSpanner {
    method StockSpanner (line 6) | StockSpanner() {
    method next (line 10) | int next(int price) {

FILE: Leetcode/stack/Remove All Adjacent Duplicates In String.cpp
  class Solution (line 3) | class Solution {
    method string (line 5) | string removeDuplicates(string s) {

FILE: Leetcode/stack/Remove All Adjacent Duplicates in String II.cpp
  class Solution (line 3) | class Solution {
    method string (line 5) | string removeDuplicates(string s, int k) {

FILE: Leetcode/stack/Reverse First K elements of Queue.cpp
  function main (line 9) | int main() {
  function modifyQueue (line 35) | queue<int> modifyQueue(queue<int> q, int k) {

FILE: Leetcode/stack/Valid Parentheses.cpp
  class Solution (line 3) | class Solution {
    method isValid (line 5) | bool isValid(string s) {

FILE: Leetcode/string/Find the Index of the First Occurrence in a String.cpp
  class Solution (line 4) | class Solution {
    method fillLPS (line 7) | vector<int> fillLPS(string str){
    method strStr (line 29) | int strStr(string haystack, string needle) {
    method strStr (line 62) | int strStr(string haystack, string needle) {
  class Solution (line 60) | class Solution {
    method fillLPS (line 7) | vector<int> fillLPS(string str){
    method strStr (line 29) | int strStr(string haystack, string needle) {
    method strStr (line 62) | int strStr(string haystack, string needle) {

FILE: Leetcode/string/Maximum Ice Cream Bars.cpp
  class Solution (line 3) | class Solution {
    method maxIceCream (line 5) | int maxIceCream(vector<int>& costs, int coins) {

FILE: Leetcode/sum of numbers in string.cpp
  function findSum (line 6) | int findSum(string s)
  function main (line 25) | int main()

FILE: STL/Array_Algorithms_in_stl.cpp
  function main (line 15) | int main(){

FILE: STL/Binary search in STL.cpp
  function show (line 13) | void show(int a[], int asize){
  function main (line 19) | int main(){

FILE: STL/List_in_STL.cpp
  function show (line 15) | void show(list<int> l){
  function main (line 23) | int main(){

FILE: STL/Queue_in_STL.cpp
  function show (line 15) | void show(queue<int> QUEUE){
  function main (line 24) | int main(){

FILE: STL/Vectors_Functions_in_STL.cpp
  function show (line 15) | void show(vector<int>v){
  function main (line 21) | int main(){

FILE: STL/What is STL.cpp
  function main (line 14) | int main(){

FILE: STL/deque_in_STL.cpp
  function showDeque (line 15) | void showDeque(deque<int> q){
  function main (line 23) | int main(){

FILE: STL/pair_in_STL.cpp
  function main (line 13) | int main(){

FILE: STL/priority Queue in STL.cpp
  function showPriorityQueue (line 15) | void showPriorityQueue(priority_queue<int> pq){
  function main (line 24) | int main(){

FILE: STL/sort_in_STL.cpp
  function showArray (line 14) | void showArray(int a[]){
  function main (line 20) | int main(){

FILE: STL/stack in STL data structure.cpp
  function printElementOfStack (line 15) | void printElementOfStack(stack<int> s){
  function main (line 22) | int main(){

FILE: Templates_in_c++.cpp
  function T (line 14) | T MAX ( T a , T b){
  class boy (line 19) | class boy {
  function main (line 23) | int main(){

FILE: Tree/Binary_tree.cpp
  type node (line 12) | struct node{
  function node (line 17) | node* newNode(int data){
  function printNode (line 34) | void printNode(node *n){
  function main (line 41) | int main(){

FILE: Tree/Code of Deletion of Node in BST.cpp
  type node (line 12) | struct node{
  function node (line 17) | node* newNode(int data){
  function inorder (line 26) | void inorder(node* root){
  function node (line 34) | node *insert(node * node, int key){
  function node (line 55) | node * minValueNode(node * node){
  function node (line 68) | node * deleteNode(node * root, int key){
  function main (line 113) | int main(){

FILE: Tree/Code of Inorder Traversal.cpp
  type node (line 12) | struct node{
  function node (line 18) | node* newNode(int data){
  function printInorder (line 27) | void printInorder(node *node){
  function main (line 42) | int main(){

FILE: Tree/Insertion in BST.cpp
  type node (line 12) | struct node{
  function node (line 17) | node* newNode(int data){
  function inorder (line 26) | void inorder(node* root){
  function node (line 34) | node *insert(node * node, int key){
  function main (line 51) | int main(){

FILE: Tree/code of Hashing in C++.cpp
  function search (line 17) | bool search(int x){
  function insert (line 34) | void insert(int a[], int n){
  function main (line 45) | int main(){

FILE: Tree/code of preorer and Postorder traversal.cpp
  type node (line 12) | struct node{
  function node (line 18) | node* newNode(int data){
  function printInorder (line 27) | void printInorder(node *node){
  function printPreorder (line 41) | void printPreorder(node *node){
  function printPostorder (line 58) | void printPostorder(node *node){
  function main (line 74) | int main(){

FILE: chef and Icecream.cpp
  function main (line 14) | int main(){

FILE: chef and string.cpp
  function main (line 14) | int main(){
Condensed preview — 212 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (221K chars).
[
  {
    "path": "35_hacker_two_strings.cpp",
    "chars": 1142,
    "preview": "//\n//  main.cpp\n//  Lecture 34\n//\n//  Created by Prince  Kumar on 17/04/19.\n//  Copyright © 2019 Prince  Kumar. All righ"
  },
  {
    "path": "36_codechef_Encoding_message.cpp",
    "chars": 1413,
    "preview": "//\n//  main.cpp\n//  Lecture 36\n//\n//  Created by Prince  Kumar on 17/04/19.\n//  Copyright © 2019 Prince  Kumar. All righ"
  },
  {
    "path": "37_codechef_spell_bob.cpp",
    "chars": 1370,
    "preview": "//\n//  main.cpp\n//  Lecture 37\n//\n//  Created by Prince  Kumar on 17/04/19.\n//  Copyright © 2019 Prince  Kumar. All righ"
  },
  {
    "path": "38_codechef_fits_square_in_triangle.cpp",
    "chars": 788,
    "preview": "//\n//  main.cpp\n//  CODECHEF\n//\n//  Created by Prince  Kumar on 14/05/19.\n//  Copyright © 2019 Prince  Kumar. All rights"
  },
  {
    "path": "39_codechef_chef_and_Eid.cpp",
    "chars": 746,
    "preview": "//\n//  main.cpp\n//  CODE-CHEF\n//\n//  Created by Prince  Kumar on 14/05/19.\n//  Copyright © 2019 Prince  Kumar. All right"
  },
  {
    "path": "40_codechef_chef_judges_competition.cpp",
    "chars": 1025,
    "preview": "//\n//  main.cpp\n//  CODE-CHEF\n//\n//  Created by Prince  Kumar on 15/05/19.\n//  Copyright © 2019 Prince  Kumar. All right"
  },
  {
    "path": "41_codechef_chef_and_glove.cpp",
    "chars": 1293,
    "preview": "//\n//  main.cpp\n//  CODE-CHEF\n//\n//  Created by Prince  Kumar on 17/05/19.\n//  Copyright © 2019 Prince  Kumar. All right"
  },
  {
    "path": "42_codechef_the_great_run.cpp",
    "chars": 743,
    "preview": "//\n//  main.cpp\n//  CODE-CHEF\n//\n//  Created by Prince  Kumar on 17/05/19.\n//  Copyright © 2019 Prince  Kumar. All right"
  },
  {
    "path": "43_codechef_attendance.cpp",
    "chars": 1059,
    "preview": "//\n//  main.cpp\n//  CODE-CHEF\n//\n//  Created by Prince  Kumar on 18/05/19.\n//  Copyright © 2019 Prince  Kumar. All right"
  },
  {
    "path": "44_codechef_making_a_meal.cpp",
    "chars": 980,
    "preview": "//\n//  main.cpp\n//  CODE-CHEF\n//\n//  Created by Prince  Kumar on 18/05/19.\n//  Copyright © 2019 Prince  Kumar. All right"
  },
  {
    "path": "45_codechef_uncle_johny.cpp",
    "chars": 849,
    "preview": "//\n//  main.cpp\n//  lecture 45\n//\n//  Created by Prince  Kumar on 25/07/19.\n//  Copyright © 2019 Prince  Kumar. All righ"
  },
  {
    "path": "46_drink_codeforce.cpp",
    "chars": 714,
    "preview": "//\n//  main.cpp\n//  hello\n//\n//  Created by Prince  Kumar on 01/08/19.\n//  Copyright © 2019 Prince  Kumar. All rights re"
  },
  {
    "path": "47_candles_codeforces.cpp",
    "chars": 297,
    "preview": "//\n//  main.cpp\n//  candles\n\n// codeforces question\n//                   A. New Year Candles\n\n\n#include <iostream>\nusing"
  },
  {
    "path": "49_two_buttons_codeforces.cpp",
    "chars": 590,
    "preview": "//\n//  main.cpp\n//  Two Buttons\n\n//\n//  Created by Prince  Kumar on 13/08/19.\n//  Copyright © 2019 Prince  Kumar. All ri"
  },
  {
    "path": "50_vanya_and_books_codeforces.cpp",
    "chars": 858,
    "preview": "//\n//  main.cpp\n//  books\n//\n//  Created by Prince  Kumar on 15/08/19.\n//  Copyright © 2019 Prince  Kumar. All rights re"
  },
  {
    "path": "51_eleven_codeforces.cpp",
    "chars": 825,
    "preview": "//\n//  main.cpp\n//  eleven\n//\n//  Created by Prince  Kumar on 21/08/19.\n//  Copyright © 2019 Prince  Kumar. All rights r"
  },
  {
    "path": "52_codechef_flatland.cpp",
    "chars": 688,
    "preview": "//\n//  main.cpp\n//  faltland\n//\n//  Created by Prince  Kumar on 05/09/19.\n//  Copyright © 2019 Prince  Kumar. All rights"
  },
  {
    "path": "53_codeforces_MUH_and_sticks.cpp",
    "chars": 1638,
    "preview": "//\n//  main.cpp\n//  code\n//\n//  Created by Prince  Kumar on 07/09/19.\n//  Copyright © 2019 Prince  Kumar. All rights res"
  },
  {
    "path": "54_print_subset_of_size_k_of_array.cpp",
    "chars": 1331,
    "preview": "//\n//  main.cpp\n//  subset\n//\n//  Created by Prince  Kumar on 09/09/19.\n//  Copyright © 2019 Prince  Kumar. All rights r"
  },
  {
    "path": "55_codechef_Easy_Fibonacci.cpp",
    "chars": 756,
    "preview": "//\n//  main.cpp\n//  fibonacciii\n//\n//  Created by Prince  Kumar on 23/09/19.\n//  Copyright © 2019 Prince  Kumar. All rig"
  },
  {
    "path": "56_codechef_Chef_and_Interesting_Subsequences.cpp",
    "chars": 1963,
    "preview": "//\n//  main.cpp\n//  code\n//\n//  Created by Prince  Kumar on 23/09/19.\n//  Copyright © 2019 Prince  Kumar. All rights res"
  },
  {
    "path": "57_codechef_A-books.cpp",
    "chars": 798,
    "preview": "//\n//  main.cpp\n//  jdjd\n//\n//  Created by Prince  Kumar on 26/09/19.\n//  Copyright © 2019 Prince  Kumar. All rights res"
  },
  {
    "path": "58_codechef_phone_prices.cpp",
    "chars": 1347,
    "preview": "//\n//  main.cpp\n//  test1\n//\n//  Created by Prince  Kumar on 06/10/19.\n//  Copyright © 2019 Prince  Kumar. All rights re"
  },
  {
    "path": "59_codechef_operations_on_a_matrix.cpp",
    "chars": 1494,
    "preview": "//\n//  main.cpp\n//  bbcfjc\n//\n//  Created by Prince  Kumar on 06/10/19.\n//  Copyright © 2019 Prince  Kumar. All rights r"
  },
  {
    "path": "60_Adding_one_to_the_numbers.cpp",
    "chars": 1035,
    "preview": "//\n//  main.cpp\n//\n//  Created by Prince  Kumar on 16/04/20.\n//  Copyright © 2020 Prince  Kumar. All rights reserved.\n//"
  },
  {
    "path": "Chef and Price Control.cpp",
    "chars": 1057,
    "preview": "//\n//  COMPETITIVE PROGRAMMING .cpp\n//\n//  Created by Prince  Kumar on 15/06/2020.\n//  Copyright © 2020 Prince  Kumar. A"
  },
  {
    "path": "Data Structures/Add a node at the Middle of linked list.cpp",
    "chars": 1308,
    "preview": "//\n//  DATA STRUCTURES.cpp\n//\n//  Created by Prince  Kumar on 23/05/2020.\n//  Copyright © 2020 Prince  Kumar. All rights"
  },
  {
    "path": "Data Structures/Add a node at the end of linked list.cpp",
    "chars": 1785,
    "preview": "//\n//  DATA STRUCTURES.cpp\n//\n//  Created by Prince  Kumar on 24/05/2020.\n//  Copyright © 2020 Prince  Kumar. All rights"
  },
  {
    "path": "Data Structures/Add a node at the front of linked list.cpp",
    "chars": 1129,
    "preview": "\n//  DATA STRUCTURES.cpp\n//\n//  Created by Prince  Kumar on 22/05/2020.\n//  Copyright © 2020 Prince  Kumar. All rights r"
  },
  {
    "path": "Data Structures/Array_in_data_structures.cpp",
    "chars": 702,
    "preview": "//\n//  DATA STRUCTURES.cpp\n//\n//  Created by Prince  Kumar on 08/05/2020.\n//  Copyright © 2020 Prince  Kumar. All rights"
  },
  {
    "path": "Data Structures/Circular Linked List data_structure.cpp",
    "chars": 1642,
    "preview": "//\n//  DATA STRUCTURES.cpp\n//\n//  Created by Prince  Kumar on 20/05/2020.\n//  Copyright © 2020 Prince  Kumar. All rights"
  },
  {
    "path": "Data Structures/Delete a node of a linked list.cpp",
    "chars": 1869,
    "preview": "//\n//  DATA STRUCTURES.cpp\n//\n//  Created by Prince  Kumar on 25/05/2020.\n//  Copyright © 2020 Prince  Kumar. All rights"
  },
  {
    "path": "Data Structures/Doubly Linked list.cpp",
    "chars": 1179,
    "preview": "//\n//  DATA STRUCTURES.cpp\n//\n//  Created by Prince  Kumar on 27/05/2020.\n//  Copyright © 2020 Prince  Kumar. All rights"
  },
  {
    "path": "Data Structures/Find the middle of a given linked list.cpp",
    "chars": 1853,
    "preview": "//\n//  DATA STRUCTURES.cpp\n//\n//  Created by Prince  Kumar on 20/05/2020.\n//  Copyright © 2020 Prince  Kumar. All rights"
  },
  {
    "path": "Data Structures/Insert Node at the End of Doubly Linked List.cpp",
    "chars": 2271,
    "preview": "//\n//  DATA STRUCTURES.cpp\n//\n//  Created by Prince  Kumar on 30/05/2020.\n//  Copyright © 2020 Prince  Kumar. All rights"
  },
  {
    "path": "Data Structures/Insert Node in Middle of Doubly Linkedlist.cpp",
    "chars": 1724,
    "preview": "//\n//  DATA STRUCTURES.cpp\n//\n//  Created by Prince  Kumar on 30/05/2020.\n//  Copyright © 2020 Prince  Kumar. All rights"
  },
  {
    "path": "Data Structures/LinkedList_Code_Practice.cpp",
    "chars": 755,
    "preview": "//\n//  DATA STRUCTURES.cpp\n//\n//  Created by Prince  Kumar on 15/05/2020.\n//  Copyright © 2020 Prince  Kumar. All rights"
  },
  {
    "path": "Data Structures/Vectors_in_STL_data_structure.cpp",
    "chars": 852,
    "preview": "//\n//  DATA STRUCTURES.cpp\n//\n//  Created by Prince  Kumar on 3/06/2020.\n//  Copyright © 2020 Prince  Kumar. All rights "
  },
  {
    "path": "Data Structures/main.cpp",
    "chars": 10,
    "preview": "main file\n"
  },
  {
    "path": "Data Structures/structure_in_c++.cpp",
    "chars": 786,
    "preview": "//\n//  DATA STRUCTURES.cpp\n//\n//  Created by Prince  Kumar on 11/05/2020.\n//  Copyright © 2020 Prince  Kumar. All rights"
  },
  {
    "path": "Kadane's_algorithm.cpp",
    "chars": 992,
    "preview": "//\n//  main.cpp\n//\n//  Created by Prince  Kumar on 21/04/20.\n//  Copyright © 2020 Prince  Kumar. All rights reserved.\n//"
  },
  {
    "path": "Lecture - 15.cpp",
    "chars": 644,
    "preview": "//\n//  main.cpp\n//  lecture 15\n//\n//  Created by Prince  Kumar on 14/03/19.\n//  Copyright © 2019 Prince  Kumar. All righ"
  },
  {
    "path": "Lecture - 16.cpp",
    "chars": 780,
    "preview": "//\n//  main.cpp\n//  lecture -16\n//\n//  Created by Prince  Kumar on 15/03/19.\n//  Copyright © 2019 Prince  Kumar. All rig"
  },
  {
    "path": "Lecture - 17.cpp",
    "chars": 412,
    "preview": "//\n//  main.cpp\n//  lecture -17\n//\n//  Created by Prince  Kumar on 17/03/19.\n//  Copyright © 2019 Prince  Kumar. All rig"
  },
  {
    "path": "Lecture - 18.cpp",
    "chars": 1202,
    "preview": "#include <iostream>\nusing namespace std;\nint main()\n{\n    int T;cin>>T;\n    while(T--)\n    {\n        int n; cin>>n;\n    "
  },
  {
    "path": "Lecture - 19.cpp",
    "chars": 971,
    "preview": "\n// ** -- code of \"Studying alphabet \" --Code chef -- **\n#include <iostream>\nusing namespace std;\nint main()\n{\n    strin"
  },
  {
    "path": "Lecture - 20.cpp",
    "chars": 448,
    "preview": "#include <iostream>\n#include <sstream>\nusing namespace std;\nint main()\n{\n    string s;\n    //cin>>s;\n    getline(cin,s);"
  },
  {
    "path": "Lecture - 21.cpp",
    "chars": 700,
    "preview": "#include <iostream>\n#include <cstring>\nusing namespace std;\nint main()\n{\n    // problem 1.\n    /*int a[10]={0};\n    cout"
  },
  {
    "path": "Lecture - 22.cpp",
    "chars": 476,
    "preview": "// **--- program of print prime numbers ---**//\n\n#include <iostream>\nusing namespace std;\nint main()\n{\n    int n;\n    co"
  },
  {
    "path": "Lecture - 24.cpp",
    "chars": 836,
    "preview": "//\n//  main.cpp\n//  Lecture - 24\n//\n//  Created by Prince  Kumar on 28/03/19.\n//  Copyright © 2019 Prince  Kumar. All ri"
  },
  {
    "path": "Lecture - 25.cpp",
    "chars": 472,
    "preview": "//\n//  main.cpp\n//  hbhbhbs\n//\n//  Created by Prince  Kumar on 29/03/19.\n//  Copyright © 2019 Prince  Kumar. All rights "
  },
  {
    "path": "Lecture - 26.cpp",
    "chars": 894,
    "preview": "//\n//  main.cpp\n//  hsgts\n//\n//  Created by Prince  Kumar on 29/03/19.\n//  Copyright © 2019 Prince  Kumar. All rights re"
  },
  {
    "path": "Lecture - 27.cpp",
    "chars": 458,
    "preview": "//\n//  main.cpp\n//  lecture 27\n//\n//  Created by Prince  Kumar on 31/03/19.\n//  Copyright © 2019 Prince  Kumar. All righ"
  },
  {
    "path": "Lecture - 31.cpp",
    "chars": 455,
    "preview": "//\n//  main.cpp\n//  lecture 31\n//\n//  Created by Prince  Kumar on 04/04/19.\n//  Copyright © 2019 Prince  Kumar. All righ"
  },
  {
    "path": "Lecture - 32.cpp",
    "chars": 681,
    "preview": "//\n//  main.cpp\n//  lecture 32\n//\n//  Created by Prince  Kumar on 05/04/19.\n//  Copyright © 2019 Prince  Kumar. All righ"
  },
  {
    "path": "Lecture - 33.cpp",
    "chars": 486,
    "preview": "//\n//  main.cpp\n//  lecture 33\n//\n//  Created by Prince  Kumar on 05/04/19.\n//  Copyright © 2019 Prince  Kumar. All righ"
  },
  {
    "path": "Lecture - 34.cpp",
    "chars": 802,
    "preview": "//\n//  main.cpp\n//  Lecture 34\n//\n//  Created by Prince  Kumar on 17/04/19.\n//  Copyright © 2019 Prince  Kumar. All righ"
  },
  {
    "path": "Leetcode/Add Digits.cpp",
    "chars": 436,
    "preview": "// https://leetcode.com/problems/add-digits/\n\n\nclass Solution {\npublic:\n    \n    int addDigitsHelper(int num){\n        i"
  },
  {
    "path": "Leetcode/Add Two Numbers Leetcode Solutions in Linkedlist.cpp",
    "chars": 980,
    "preview": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n *     int val;\n *     ListNode *next;\n *     ListNode() "
  },
  {
    "path": "Leetcode/Binary Search leetcode Solution.cpp",
    "chars": 560,
    "preview": "// https://leetcode.com/problems/binary-search/\n\n\nclass Solution {\npublic:\n    int search(vector<int>& nums, int target)"
  },
  {
    "path": "Leetcode/Boolean Matrix.cpp",
    "chars": 1017,
    "preview": "// Boolean Matrix: https://practice.geeksforgeeks.org/problems/boolean-matrix-problem-1587115620/1#\n\nvoid booleanMatrix("
  },
  {
    "path": "Leetcode/Count the Number of Consistent Strings.cpp",
    "chars": 651,
    "preview": "// https://leetcode.com/problems/count-the-number-of-consistent-strings/\n\nclass Solution {\npublic:\n    int countConsiste"
  },
  {
    "path": "Leetcode/Graph/All Paths From Source to Target.cpp",
    "chars": 697,
    "preview": "// https://leetcode.com/problems/all-paths-from-source-to-target/\n\nclass Solution {\npublic:\n    \n    void dfs(vector<vec"
  },
  {
    "path": "Leetcode/Graph/Course Schedule.cpp",
    "chars": 1250,
    "preview": "// https://leetcode.com/problems/course-schedule/\n\nclass Solution {\npublic:\n    \n    bool DFSRec(int s, vector<bool>&vis"
  },
  {
    "path": "Leetcode/Graph/Detect cycle in a directed graph.cpp",
    "chars": 1024,
    "preview": "// https://practice.geeksforgeeks.org/problems/detect-cycle-in-a-directed-graph/1\n\nclass Solution {\n  public:\n    // Fun"
  },
  {
    "path": "Leetcode/Graph/Find Eventual Safe States.cpp",
    "chars": 1300,
    "preview": "// https://leetcode.com/problems/find-eventual-safe-states/\n\nclass Solution {\npublic:\n    \n    bool DFSRec(int s, vector"
  },
  {
    "path": "Leetcode/Graph/Find if Path Exists in Graph.cpp",
    "chars": 1154,
    "preview": "// https://leetcode.com/problems/find-if-path-exists-in-graph/\n\nclass Solution {\npublic:\n    bool validPath(int n, vecto"
  },
  {
    "path": "Leetcode/Graph/Find the Town Judge.cpp",
    "chars": 445,
    "preview": "// https://leetcode.com/problems/find-the-town-judge/\n\nclass Solution {\npublic:\n    int findJudge(int n, vector<vector<i"
  },
  {
    "path": "Leetcode/Graph/Flood Fill.cpp",
    "chars": 1338,
    "preview": "// https://leetcode.com/problems/flood-fill/\n\nclass Solution {\npublic:\n    \n    bool isValid(vector<vector<int>>& image,"
  },
  {
    "path": "Leetcode/Graph/Keys and Rooms.cpp",
    "chars": 723,
    "preview": "// https://leetcode.com/problems/keys-and-rooms/\n\nclass Solution {\npublic:\n    bool canVisitAllRooms(vector<vector<int>>"
  },
  {
    "path": "Leetcode/Graph/Max Area of Island.cpp",
    "chars": 1262,
    "preview": "// https://leetcode.com/problems/max-area-of-island/\n\nclass Solution {\npublic:\n    \n    bool isValid(int i, int j, int n"
  },
  {
    "path": "Leetcode/Graph/Minimum Time to Collect All Apples in a Tree.cpp",
    "chars": 896,
    "preview": "// https://leetcode.com/problems/minimum-time-to-collect-all-apples-in-a-tree/\n\nclass Solution {\npublic:\n    vector<bool"
  },
  {
    "path": "Leetcode/Graph/Number of Enclaves.cpp",
    "chars": 1846,
    "preview": "// https://leetcode.com/problems/number-of-enclaves/\n\nclass Solution {\npublic:\n    \n    int count(vector<vector<int>>& g"
  },
  {
    "path": "Leetcode/Graph/Number of Islands.cpp",
    "chars": 1230,
    "preview": "// https://leetcode.com/problems/number-of-islands/\n\nclass Solution {\npublic:\n    \n    \n    bool isValid(int i, int j, i"
  },
  {
    "path": "Leetcode/Graph/Number of Provinces.cpp",
    "chars": 1055,
    "preview": "// https://leetcode.com/problems/number-of-provinces/\n\nclass Solution {\npublic:\n    \n    void dfs(int s, int n, vector<v"
  },
  {
    "path": "Leetcode/Graph/Number of closed Islands.cpp",
    "chars": 1493,
    "preview": "// https://leetcode.com/problems/number-of-closed-islands/\n\nclass Solution {\npublic:\n    \n    \n    bool isValid(int i, i"
  },
  {
    "path": "Leetcode/Graph/Rotting Oranges.cpp",
    "chars": 2134,
    "preview": "// https://leetcode.com/problems/rotting-oranges/\n\nclass Solution {\npublic:\n    \n    \n    bool isValid(int i, int j, int"
  },
  {
    "path": "Leetcode/Graph/Steps by Knight.cpp",
    "chars": 1683,
    "preview": "// https://practice.geeksforgeeks.org/problems/steps-by-knight5927/1\n\nclass Solution \n{\n    public:\n    //Function to fi"
  },
  {
    "path": "Leetcode/Graph/Surrounded Regions.cpp",
    "chars": 2079,
    "preview": "// https://leetcode.com/problems/surrounded-regions/\n\nclass Solution {\npublic:\n    \n    void convert(vector<vector<char>"
  },
  {
    "path": "Leetcode/Graph/Time Needed to Inform All Employees.cpp",
    "chars": 825,
    "preview": "// https://leetcode.com/problems/time-needed-to-inform-all-employees/\n\n\nclass Solution {\npublic:\n    \n    unordered_map<"
  },
  {
    "path": "Leetcode/Graph/Topological sort .cpp",
    "chars": 828,
    "preview": "// https://practice.geeksforgeeks.org/problems/topological-sort/1\n\nclass Solution\n{\n\tpublic:\n\t//Function to return list "
  },
  {
    "path": "Leetcode/Graph/Topological sort using dfs.cpp",
    "chars": 924,
    "preview": "// https://practice.geeksforgeeks.org/problems/topological-sort/1\n\n#include <bits/stdc++.h>\nusing namespace std;\n\n // } "
  },
  {
    "path": "Leetcode/Hashing/Check if two arrays are equal or not.cpp",
    "chars": 751,
    "preview": "// Question Link: https://practice.geeksforgeeks.org/problems/check-if-two-arrays-are-equal-or-not3847/1\n\nclass Solution"
  },
  {
    "path": "Leetcode/Hashing/Custom Sort String.cpp",
    "chars": 671,
    "preview": "// https://leetcode.com/problems/custom-sort-string/\n\nclass Solution {\npublic:\n    string customSortString(string order,"
  },
  {
    "path": "Leetcode/Hashing/First Repeating Element.cpp",
    "chars": 594,
    "preview": "// Question Link: https://practice.geeksforgeeks.org/problems/first-repeating-element4018/1\n\nclass Solution{\n    public:"
  },
  {
    "path": "Leetcode/Hashing/Group Anagrams.cpp",
    "chars": 497,
    "preview": "// https://leetcode.com/problems/group-anagrams/\n\nclass Solution {\npublic:\n    vector<vector<string>> groupAnagrams(vect"
  },
  {
    "path": "Leetcode/Hashing/Intersection of two arrays.cpp",
    "chars": 461,
    "preview": "// Question Link: https://practice.geeksforgeeks.org/problems/intersection-of-two-arrays2404/1\n\nint NumberofElementsInIn"
  },
  {
    "path": "Leetcode/Hashing/Key Pair.cpp",
    "chars": 724,
    "preview": "// Problem Link: https://practice.geeksforgeeks.org/problems/key-pair5616/1\n\nclass Solution{\npublic:\t\n\t// Function to ch"
  },
  {
    "path": "Leetcode/Hashing/LFU Cache.cpp",
    "chars": 1871,
    "preview": "/* https://leetcode.com/problems/lfu-cache/ */\n\nclass LFUCache {\npublic:\n    int capacity, minFreq;\n    unordered_map<in"
  },
  {
    "path": "Leetcode/Hashing/Non-Repeating Element.cpp",
    "chars": 582,
    "preview": "// Question Link: https://practice.geeksforgeeks.org/problems/non-repeating-element3958/1\n\n\nclass Solution{\n    public:\n"
  },
  {
    "path": "Leetcode/Hashing/Pairs with Positive Negative values.cpp",
    "chars": 683,
    "preview": "// https://practice.geeksforgeeks.org/problems/pairs-with-positive-negative-values3719/1\n\n\nclass Solution{\n  public:\n   "
  },
  {
    "path": "Leetcode/Hashing/Relative Sort Array.cpp",
    "chars": 833,
    "preview": "// https://leetcode.com/problems/relative-sort-array/\n\nclass Solution {\npublic:\n    vector<int> relativeSortArray(vector"
  },
  {
    "path": "Leetcode/Hashing/Sort Array by Increasing Frequency.cpp",
    "chars": 429,
    "preview": "// https://leetcode.com/problems/sort-array-by-increasing-frequency/\n\nclass Solution {\npublic:\n    vector<int> frequency"
  },
  {
    "path": "Leetcode/Hashing/Subarray with 0 sum.cpp",
    "chars": 635,
    "preview": "// Link: https://practice.geeksforgeeks.org/problems/subarray-with-0-sum-1587115621/1\n\nclass Solution{\n    public:\n    /"
  },
  {
    "path": "Leetcode/Hashing/Winner of an election.cpp",
    "chars": 1188,
    "preview": "//  https://practice.geeksforgeeks.org/problems/winner-of-an-election-where-votes-are-represented-as-candidate-names-158"
  },
  {
    "path": "Leetcode/Hashing/unordered_map.cpp",
    "chars": 1126,
    "preview": "#include<bits/stdc++.h>\n#include<unordered_map>\n\nusing namespace std;\nint main(){\n    unordered_map<string,int> umap;\n  "
  },
  {
    "path": "Leetcode/Hashing/unordered_set.cpp",
    "chars": 898,
    "preview": "#include<bits/stdc++.h>\n#include<unordered_set>\n\nusing namespace std;\nint main(){\n\n    unordered_set<int> s;\n    s.inser"
  },
  {
    "path": "Leetcode/Interchanging the rows of a Matrix.cpp",
    "chars": 434,
    "preview": "// problems: https://practice.geeksforgeeks.org/problems/reversing-the-rows-of-a-matrix-1587115621/1/?track=DSASP-Matrix"
  },
  {
    "path": "Leetcode/Majority Element Geeksforgeeks leetcode Moore's Voting Algorithm.cpp",
    "chars": 905,
    "preview": "// https://practice.geeksforgeeks.org/problems/majority-element/0\n\n\n#include<bits/stdc++.h>\nusing namespace std;\n\n// Fun"
  },
  {
    "path": "Leetcode/Median of Two sorted arrays.cpp",
    "chars": 957,
    "preview": "// https://practice.geeksforgeeks.org/problems/median-of-two-sorted-arrays1618/1/?track=DSASP-Searching&batchId=154\n\n\n//"
  },
  {
    "path": "Leetcode/Middle of the Linked List Leetcode.cpp",
    "chars": 831,
    "preview": "// https://leetcode.com/problems/middle-of-the-linked-list/\n\n\n/**\n * Definition for singly-linked list.\n * struct ListNo"
  },
  {
    "path": "Leetcode/Middle of the Linked List.cpp",
    "chars": 940,
    "preview": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n *     int val;\n *     ListNode *next;\n *     ListNode() "
  },
  {
    "path": "Leetcode/Move Zeroes.cpp",
    "chars": 395,
    "preview": "// https://leetcode.com/problems/move-zeroes/\n\nclass Solution {\npublic:\n    void moveZeroes(vector<int>& nums) {\n       "
  },
  {
    "path": "Leetcode/Multiply two matrices.cpp",
    "chars": 861,
    "preview": "// Problem link: https://practice.geeksforgeeks.org/problems/multiply-the-matrices-1587115620/1\n\nvector<vector<int> > mu"
  },
  {
    "path": "Leetcode/Naive Pattern Search.cpp",
    "chars": 519,
    "preview": "GFG : https://practice.geeksforgeeks.org/problems/naive-pattern-search-1587115620/1/\nLeetcode : https://leetcode.com/pro"
  },
  {
    "path": "Leetcode/Next Greater Element.cpp",
    "chars": 764,
    "preview": "// https://practice.geeksforgeeks.org/problems/next-larger-element-1587115620/1\n\n\n{\n    public:\n    //Function to find t"
  },
  {
    "path": "Leetcode/Non Repeating Character.cpp",
    "chars": 345,
    "preview": "// Complete this function\nchar nonrepeatingCharacter(string s)\n{\n   int chars = 256;\n   int n = s.size();\n   \n   int arr"
  },
  {
    "path": "Leetcode/Peak element.cpp",
    "chars": 511,
    "preview": "// https://practice.geeksforgeeks.org/problems/peak-element/1\n\nint peakElement(int arr[], int n)\n{\n   // Your code here\n"
  },
  {
    "path": "Leetcode/Rearrange Array Alternately Geeksforgeeks.cpp",
    "chars": 1100,
    "preview": "// https://practice.geeksforgeeks.org/problems/-rearrange-array-alternately/0\n\n#include <iostream>\nusing namespace std;\n"
  },
  {
    "path": "Leetcode/Recursion/0-1 Knapsack Problem Top down.cpp",
    "chars": 827,
    "preview": "// https://practice.geeksforgeeks.org/problems/0-1-knapsack-problem0945/1\n\nclass Solution\n{\n    public:\n    //Function t"
  },
  {
    "path": "Leetcode/Recursion/Best Time to Buy and Sell Stock.cpp",
    "chars": 453,
    "preview": "// https://leetcode.com/problems/best-time-to-buy-and-sell-stock/\n\nclass Solution {\npublic:\n    int maxProfit(vector<int"
  },
  {
    "path": "Leetcode/Recursion/Climbing Stairs.cpp",
    "chars": 293,
    "preview": "// https://leetcode.com/problems/climbing-stairs/\n\nvector<int>dp(46, -1);\nclass Solution {\npublic:\n    int climbStairs(i"
  },
  {
    "path": "Leetcode/Recursion/Decode Ways.cpp",
    "chars": 622,
    "preview": "// https://leetcode.com/problems/decode-ways/\n\nvector<int>dp(101, -1);\nclass Solution {\npublic:\n    int n = 0;\n    int n"
  },
  {
    "path": "Leetcode/Recursion/Delete middle element of a stack.cpp",
    "chars": 618,
    "preview": "// https://practice.geeksforgeeks.org/problems/delete-middle-element-of-a-stack/1\n\nclass Solution\n{\n    public:\n    //Fu"
  },
  {
    "path": "Leetcode/Recursion/Divisor Game.cpp",
    "chars": 362,
    "preview": "// https://leetcode.com/problems/divisor-game/\n\nclass Solution {\npublic:\n    bool divisorGame(int n) {\n        // if(n<="
  },
  {
    "path": "Leetcode/Recursion/Factorial.cpp",
    "chars": 215,
    "preview": "// https://practice.geeksforgeeks.org/problems/factorial5739/1\n\nclass Solution{\npublic:\n    long long int factorial(int "
  },
  {
    "path": "Leetcode/Recursion/Fibonacci Number.cpp",
    "chars": 168,
    "preview": "// https://leetcode.com/problems/fibonacci-number/\n\nclass Solution {\npublic:\n    int fib(int n) {\n        if(n<=1) retur"
  },
  {
    "path": "Leetcode/Recursion/House Robber.cpp",
    "chars": 453,
    "preview": "// https://leetcode.com/problems/house-robber/\n\nvector<int>dp(101, -1);\nclass Solution {\npublic:\n    int fun(vector<int>"
  },
  {
    "path": "Leetcode/Recursion/Largest Element in Array.cpp",
    "chars": 243,
    "preview": "// https://practice.geeksforgeeks.org/problems/largest-element-in-array4009/1\n\nclass Solution\n{\npublic:\n    int largest("
  },
  {
    "path": "Leetcode/Recursion/Min Cost Climbing Stairs.cpp",
    "chars": 566,
    "preview": "// https://leetcode.com/problems/min-cost-climbing-stairs/\n\nvector<int>dp(1001, -1);\nclass Solution {\npublic:\n\n    int m"
  },
  {
    "path": "Leetcode/Recursion/Nth Fibonacci Number.cpp",
    "chars": 415,
    "preview": "// https://practice.geeksforgeeks.org/problems/nth-fibonacci-number1335/1\n\nvector<long long int>dp(1001, -1);\nclass Solu"
  },
  {
    "path": "Leetcode/Recursion/Partition Equal Subset Sum.cpp",
    "chars": 2552,
    "preview": "// https://leetcode.com/problems/partition-equal-subset-sum/\n\n/****************************** RECURSION ****************"
  },
  {
    "path": "Leetcode/Recursion/Perfect Squares.cpp",
    "chars": 465,
    "preview": "// https://leetcode.com/problems/perfect-squares/\n\nvector<int>dp(10001, -1);\nclass Solution {\npublic:\n    int solve(int "
  },
  {
    "path": "Leetcode/Recursion/Perfect Sum Problem.cpp",
    "chars": 1936,
    "preview": "// https://practice.geeksforgeeks.org/problems/perfect-sum-problem5633/1\n\n\n/****************************** RECURSION ***"
  },
  {
    "path": "Leetcode/Recursion/Power Of Numbers.cpp",
    "chars": 530,
    "preview": "// https://practice.geeksforgeeks.org/problems/power-of-numbers-1587115620/1\n\nclass Solution{\n    public:\n    //You need"
  },
  {
    "path": "Leetcode/Recursion/Print 1 To N Without Loop.cpp",
    "chars": 286,
    "preview": "// https://practice.geeksforgeeks.org/problems/print-1-to-n-without-using-loops-1587115620/1\n\nclass Solution{\n    public"
  },
  {
    "path": "Leetcode/Recursion/Reverse a String.cpp",
    "chars": 223,
    "preview": "// https://practice.geeksforgeeks.org/problems/reverse-a-string/1\n\nstring reverseWord(string str){\n    \n  //Your code he"
  },
  {
    "path": "Leetcode/Recursion/Subset Sum Problem.cpp",
    "chars": 1579,
    "preview": "// https://practice.geeksforgeeks.org/problems/subset-sum-problem-1611555638/1\n\n/****************************** RECURSIO"
  },
  {
    "path": "Leetcode/Recursion/Sum of Array.cpp",
    "chars": 273,
    "preview": "// https://practice.geeksforgeeks.org/problems/sum-of-array2326/1\n\nclass Solution{\npublic:\n\t// function to return sum of"
  },
  {
    "path": "Leetcode/Recursion/Target Sum.cpp",
    "chars": 1005,
    "preview": "// https://leetcode.com/problems/target-sum/\n\nclass Solution {\npublic:\n\n\t\tint countSubset(vector<int>& nums, int n, int "
  },
  {
    "path": "Leetcode/Recursion/Tower Of Hanoi.cpp",
    "chars": 677,
    "preview": "// https://practice.geeksforgeeks.org/problems/tower-of-hanoi-1587115621/1\n\nclass Solution{\n    public:\n    // You need "
  },
  {
    "path": "Leetcode/Reverse Linked List.cpp",
    "chars": 656,
    "preview": "// https://leetcode.com/problems/reverse-linked-list/\n\n/**\n * Definition for singly-linked list.\n * struct ListNode {\n *"
  },
  {
    "path": "Leetcode/Rotate Array Leetcode.cpp",
    "chars": 416,
    "preview": "class Solution {\npublic:\n    \n    void reverse(vector<int> &num, int low, int high){\n        while(low < high){\n        "
  },
  {
    "path": "Leetcode/Rotate List.cpp",
    "chars": 1310,
    "preview": "// https://leetcode.com/problems/rotate-list/\n\n\n/**\n * Definition for singly-linked list.\n * struct ListNode {\n *     in"
  },
  {
    "path": "Leetcode/Search in a row-column sorted Matrix.cpp",
    "chars": 562,
    "preview": "// https://practice.geeksforgeeks.org/problems/search-in-a-matrix-1587115621/1\n\n\n\nbool search(vector<vector<int> > matri"
  },
  {
    "path": "Leetcode/Single Number Leetcode solution.cpp",
    "chars": 289,
    "preview": "//https://leetcode.com/problems/single-number/\n\n\n\nclass Solution {\npublic:\n    int singleNumber(vector<int>& nums) {\n   "
  },
  {
    "path": "Leetcode/Sort Array By Parity.cpp",
    "chars": 409,
    "preview": "class Solution {\npublic:\n    vector<int> sortArrayByParity(vector<int>& A) {\n       vector<int> odd;\n       vector<int> "
  },
  {
    "path": "Leetcode/Sort Colors.cpp",
    "chars": 1287,
    "preview": "// https://leetcode.com/problems/sort-colors/\n\n// or\n\n// https://practice.geeksforgeeks.org/problems/sort-an-array-of-0s"
  },
  {
    "path": "Leetcode/Spirally traversing a matrix.cpp",
    "chars": 1087,
    "preview": "Spirally traversing a matrix: https://practice.geeksforgeeks.org/problems/spirally-traversing-a-matrix-1587115621/1\n\ncla"
  },
  {
    "path": "Leetcode/Square root.cpp",
    "chars": 801,
    "preview": "// https://practice.geeksforgeeks.org/problems/square-root/1\n\n\n\n#include<bits/stdc++.h>\nusing namespace std;\n\nlong long "
  },
  {
    "path": "Leetcode/Subarray sum equals K.cpp",
    "chars": 528,
    "preview": "class Solution {\npublic:\n    int subarraySum(vector<int>& nums, int k) {\n        int n  =(int)nums.size();\n        \n    "
  },
  {
    "path": "Leetcode/Trapping Rain Water.cpp",
    "chars": 1076,
    "preview": "#include <iostream>\nusing namespace std;\n\n// function to find the trapped water in between buildings\n// arr: input array"
  },
  {
    "path": "Leetcode/Tree/Balanced Binary Tree.cpp",
    "chars": 1109,
    "preview": "// https://leetcode.com/problems/balanced-binary-tree/\n\n/**\n * Definition for a binary tree node.\n * struct TreeNode {\n "
  },
  {
    "path": "Leetcode/Tree/Binary Tree Inorder Traversal.cpp",
    "chars": 803,
    "preview": "// https://leetcode.com/problems/binary-tree-inorder-traversal/\n\n\n/**\n * Definition for a binary tree node.\n * struct Tr"
  },
  {
    "path": "Leetcode/Tree/Binary Tree Right Side View.cpp",
    "chars": 1189,
    "preview": "// https://leetcode.com/problems/binary-tree-right-side-view/\n\n/**\n * Definition for a binary tree node.\n * struct TreeN"
  },
  {
    "path": "Leetcode/Tree/Binary Tree Zigzag Level Order Traversal.cpp",
    "chars": 975,
    "preview": "// https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/\n\nvector<vector<int>> zigzagLevelOrder(TreeNod"
  },
  {
    "path": "Leetcode/Tree/Children Sum Parent.cpp",
    "chars": 511,
    "preview": "// https://practice.geeksforgeeks.org/problems/children-sum-parent/1/\n\nint isSumProperty(Node *root)\n{\n  if( root == NUL"
  },
  {
    "path": "Leetcode/Tree/Construct Binary Tree from Preorder and Inorder Traversal.cpp",
    "chars": 1300,
    "preview": "// https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/\n\n/**\n * Definition for a bin"
  },
  {
    "path": "Leetcode/Tree/Diameter of Binary Tree.cpp",
    "chars": 848,
    "preview": "// https://leetcode.com/problems/diameter-of-binary-tree/\n\n/**\n * Definition for a binary tree node.\n * struct TreeNode "
  },
  {
    "path": "Leetcode/Tree/Invert Binary Tree.cpp",
    "chars": 858,
    "preview": "// https://leetcode.com/problems/invert-binary-tree/\n\n/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * "
  },
  {
    "path": "Leetcode/Tree/Level Order Traversal.cpp",
    "chars": 829,
    "preview": "// https://leetcode.com/problems/binary-tree-level-order-traversal/\n\nvector<vector<int>> levelOrder(TreeNode* root) {\n  "
  },
  {
    "path": "Leetcode/Tree/Lowest Common Ancestor of a Binary Tree.cpp",
    "chars": 1925,
    "preview": "// https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/\n\n\n//                  METHOD - 01\n\n\n/**\n * Def"
  },
  {
    "path": "Leetcode/Tree/Maximum Depth of Binary Tree.cpp",
    "chars": 268,
    "preview": "// https://leetcode.com/problems/maximum-depth-of-binary-tree/\n\nclass Solution {\npublic:\n    int maxDepth(TreeNode* root"
  },
  {
    "path": "Leetcode/Tree/Populating Next Right Pointers in Each Node.cpp",
    "chars": 1475,
    "preview": "// https://leetcode.com/problems/populating-next-right-pointers-in-each-node/\n\n/*\n// Definition for a Node.\nclass Node {"
  },
  {
    "path": "Leetcode/Tree/Subtree of Another Tree.cpp",
    "chars": 1370,
    "preview": "// https://leetcode.com/problems/subtree-of-another-tree/\n\n/**\n * Definition for a binary tree node.\n * struct TreeNode "
  },
  {
    "path": "Leetcode/Tree/Symmetric Tree.cpp",
    "chars": 1085,
    "preview": "// https://leetcode.com/problems/symmetric-tree/\n\n/**\n * Definition for a binary tree node.\n * struct TreeNode {\n *     "
  },
  {
    "path": "Leetcode/Tree/Vertical Width of a Binary Tree .cpp",
    "chars": 660,
    "preview": "// https://practice.geeksforgeeks.org/problems/vertical-width-of-a-binary-tree/1\n\n\n\n/*Structure of node of binary tree i"
  },
  {
    "path": "Leetcode/Tree/same Tree.cpp",
    "chars": 1728,
    "preview": "// https://leetcode.com/problems/same-tree/\n\n\n/**\n * Definition for a binary tree node.\n * struct TreeNode {\n *     int "
  },
  {
    "path": "Leetcode/count 1's in binary array.cpp",
    "chars": 1864,
    "preview": "// https://practice.geeksforgeeks.org/problems/count-1s-in-binary-array-1587115620/1\n\n\n\n#include <bits/stdc++.h>\nusing n"
  },
  {
    "path": "Leetcode/linked-list-cycle.cpp",
    "chars": 673,
    "preview": "// https://leetcode.com/problems/linked-list-cycle/\n\n\n/**\n * Definition for singly-linked list.\n * struct ListNode {\n * "
  },
  {
    "path": "Leetcode/linkedlist/Copy List with Random Pointer.cpp",
    "chars": 1101,
    "preview": "// https://leetcode.com/problems/copy-list-with-random-pointer/\n\n\n/*\n// Definition for a Node.\nclass Node {\npublic:\n    "
  },
  {
    "path": "Leetcode/linkedlist/Delete Node in a Linked List.cpp",
    "chars": 237,
    "preview": "// https://leetcode.com/problems/delete-node-in-a-linked-list/\n\nclass Solution {\npublic:\n    void deleteNode(ListNode* n"
  },
  {
    "path": "Leetcode/linkedlist/Intersection of Two Linked Lists.cpp",
    "chars": 1006,
    "preview": "// https://leetcode.com/problems/intersection-of-two-linked-lists/\n\n/**\n * Definition for singly-linked list.\n * struct "
  },
  {
    "path": "Leetcode/linkedlist/Linked List Cycle II.cpp",
    "chars": 1129,
    "preview": "// https://leetcode.com/problems/linked-list-cycle-ii/\n\n/**\n * Definition for singly-linked list.\n * struct ListNode {\n "
  },
  {
    "path": "Leetcode/linkedlist/Merge Two Sorted Lists.cpp",
    "chars": 1129,
    "preview": "// https://leetcode.com/problems/merge-two-sorted-lists/\n\n/**\n * Definition for singly-linked list.\n * struct ListNode {"
  },
  {
    "path": "Leetcode/linkedlist/Palindrome Linked List.cpp",
    "chars": 1127,
    "preview": "// https://leetcode.com/problems/palindrome-linked-list/\n\n/**\n * Definition for singly-linked list.\n * struct ListNode {"
  },
  {
    "path": "Leetcode/linkedlist/Remove Duplicates from Sorted List.cpp",
    "chars": 521,
    "preview": "// https://leetcode.com/problems/remove-duplicates-from-sorted-list/\n\nclass Solution {\npublic:\n    ListNode* deleteDupli"
  },
  {
    "path": "Leetcode/linkedlist/Remove Nth Node From End of List.cpp",
    "chars": 772,
    "preview": "// https://leetcode.com/problems/remove-nth-node-from-end-of-list/\n\n/**\n * Definition for singly-linked list.\n * struct "
  },
  {
    "path": "Leetcode/linkedlist/Remove duplicates from an unsorted linked list.cpp",
    "chars": 967,
    "preview": "// https://practice.geeksforgeeks.org/problems/remove-duplicates-from-an-unsorted-linked-list/0\n\n/*\nThe structure of lin"
  },
  {
    "path": "Leetcode/linkedlist/Reverse Linked List.cpp",
    "chars": 630,
    "preview": "// https://leetcode.com/problems/reverse-linked-list/\n\n/**\n * Definition for singly-linked list.\n * struct ListNode {\n *"
  },
  {
    "path": "Leetcode/linkedlist/Sort List.cpp",
    "chars": 1665,
    "preview": "// https://leetcode.com/problems/sort-list/\n\n/**\n * Definition for singly-linked list.\n * struct ListNode {\n *     int v"
  },
  {
    "path": "Leetcode/linkedlist/Swap Nodes in Pairs.cpp",
    "chars": 889,
    "preview": "// https://leetcode.com/problems/swap-nodes-in-pairs/\n\n/**\n * Definition for singly-linked list.\n * struct ListNode {\n *"
  },
  {
    "path": "Leetcode/linkedlist/Swapping Nodes in a Linked List.cpp",
    "chars": 742,
    "preview": "// https://leetcode.com/problems/swapping-nodes-in-a-linked-list/\n\n/**\n * Definition for singly-linked list.\n * struct L"
  },
  {
    "path": "Leetcode/stack/Evaluate Reverse Polish Notation.cpp",
    "chars": 928,
    "preview": "// https://leetcode.com/problems/evaluate-reverse-polish-notation/\n\nclass Solution {\npublic:\n    int evalRPN(vector<stri"
  },
  {
    "path": "Leetcode/stack/Implement Queue using Stacks.cpp",
    "chars": 845,
    "preview": "// https://leetcode.com/problems/implement-queue-using-stacks/\n\nclass MyQueue {\n\nprivate:\n    stack<int>input, output;\n "
  },
  {
    "path": "Leetcode/stack/Implement Stack using Queues.cpp",
    "chars": 830,
    "preview": "// https://leetcode.com/problems/implement-stack-using-queues/\n\nclass MyStack {\npublic:\n    queue<int>q1,q2;\n    \n    \n "
  },
  {
    "path": "Leetcode/stack/Largest Rectangle in Histogram.cpp",
    "chars": 1392,
    "preview": "// https://leetcode.com/problems/largest-rectangle-in-histogram/\n\nclass Solution {\npublic:\n    \n    vector<int> previous"
  },
  {
    "path": "Leetcode/stack/Min Stack.cpp",
    "chars": 721,
    "preview": "// https://leetcode.com/problems/min-stack/\n\nclass MinStack {\npublic:\n    \n    stack<int>st, s2;\n    MinStack() {\n      "
  },
  {
    "path": "Leetcode/stack/Next Greater Element I.cpp",
    "chars": 686,
    "preview": "// https://leetcode.com/problems/next-greater-element-i/\n\nclass Solution {\npublic:\n    vector<int> nextGreaterElement(ve"
  },
  {
    "path": "Leetcode/stack/Online Stock Span.cpp",
    "chars": 574,
    "preview": "// https://leetcode.com/problems/online-stock-span/\n\nclass StockSpanner {\npublic:\n    stack<pair<int,int>>st; // price, "
  },
  {
    "path": "Leetcode/stack/Remove All Adjacent Duplicates In String.cpp",
    "chars": 628,
    "preview": "// https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string/\n\nclass Solution {\npublic:\n    string removeDu"
  },
  {
    "path": "Leetcode/stack/Remove All Adjacent Duplicates in String II.cpp",
    "chars": 654,
    "preview": "// https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string-ii/\n\nclass Solution {\npublic:\n    string remov"
  },
  {
    "path": "Leetcode/stack/Reverse First K elements of Queue.cpp",
    "chars": 1130,
    "preview": "// https://practice.geeksforgeeks.org/problems/reverse-first-k-elements-of-queue/1/\n\n// { Driver Code Starts\n// Initial "
  },
  {
    "path": "Leetcode/stack/Valid Parentheses.cpp",
    "chars": 600,
    "preview": "// https://leetcode.com/problems/valid-parentheses/\n\nclass Solution {\npublic:\n    bool isValid(string s) {\n        stack"
  },
  {
    "path": "Leetcode/string/Find the Index of the First Occurrence in a String.cpp",
    "chars": 2058,
    "preview": "// https://leetcode.com/problems/find-the-index-of-the-first-occurrence-in-a-string/\n// Pattern Matching Algorithm by us"
  },
  {
    "path": "Leetcode/string/Gas Station.cpp",
    "chars": 482,
    "preview": "// https://leetcode.com/problems/gas-station/\n\nSolution {\npublic:\n    int canCompleteCircuit(vector<int>& gas, vector<in"
  },
  {
    "path": "Leetcode/string/Maximum Ice Cream Bars.cpp",
    "chars": 341,
    "preview": "// https://leetcode.com/problems/maximum-ice-cream-bars/\n\nclass Solution {\npublic:\n    int maxIceCream(vector<int>& cost"
  },
  {
    "path": "Leetcode/sum of numbers in string.cpp",
    "chars": 527,
    "preview": "// https://practice.geeksforgeeks.org/problems/sum-of-numbers-in-string/0\n\n#include <iostream>\nusing namespace std;\n\nint"
  },
  {
    "path": "README.md",
    "chars": 551,
    "preview": "# Competitive Programming by </ <a href=\"https://www.youtube.com/channel/UCbW63uLlDnsL7l992Z9nF_Q/\" target=\"_blank\">HELL"
  },
  {
    "path": "STL/Array_Algorithms_in_stl.cpp",
    "chars": 1321,
    "preview": "//  DATA STRUCTURES.cpp\n//\n//  Created by Prince  Kumar on 26/06/2020.\n//  Copyright © 2020 Prince  Kumar. All rights re"
  },
  {
    "path": "STL/Binary search in STL.cpp",
    "chars": 832,
    "preview": "//  DATA STRUCTURES.cpp\n//\n//  Created by Prince  Kumar on 28/06/2020.\n//  Copyright © 2020 Prince  Kumar. All rights re"
  },
  {
    "path": "STL/List_in_STL.cpp",
    "chars": 978,
    "preview": "//\n//  DATA STRUCTURES.cpp\n//\n//  Created by Prince  Kumar on 8/06/2020.\n//  Copyright © 2020 Prince  Kumar. All rights "
  },
  {
    "path": "STL/Queue_in_STL.cpp",
    "chars": 738,
    "preview": "//\n//  DATA STRUCTURES.cpp\n//\n//  Created by Prince  Kumar on 8/06/2020.\n//  Copyright © 2020 Prince  Kumar. All rights "
  },
  {
    "path": "STL/Vectors_Functions_in_STL.cpp",
    "chars": 1074,
    "preview": "//  DATA STRUCTURES.cpp\n//\n//  Created by Prince  Kumar on 29/06/2020.\n//  Copyright © 2020 Prince  Kumar. All rights re"
  },
  {
    "path": "STL/What is STL.cpp",
    "chars": 483,
    "preview": "//\n//  DATA STRUCTURES.cpp\n//\n//  Created by Prince  Kumar on 31/05/2020.\n//  Copyright © 2020 Prince  Kumar. All rights"
  },
  {
    "path": "STL/deque_in_STL.cpp",
    "chars": 921,
    "preview": "//\n//  DATA STRUCTURES.cpp\n//\n//  Created by Prince  Kumar on 13/06/2020.\n//  Copyright © 2020 Prince  Kumar. All rights"
  },
  {
    "path": "STL/pair_in_STL.cpp",
    "chars": 1255,
    "preview": "//  DATA STRUCTURES.cpp\n//\n//  Created by Prince  Kumar on 19/06/2020.\n//  Copyright © 2020 Prince  Kumar. All rights re"
  },
  {
    "path": "STL/priority Queue in STL.cpp",
    "chars": 745,
    "preview": "//\n//  DATA STRUCTURES.cpp\n//\n//  Created by Prince  Kumar on 14/06/2020.\n//  Copyright © 2020 Prince  Kumar. All rights"
  },
  {
    "path": "STL/sort_in_STL.cpp",
    "chars": 840,
    "preview": "//  DATA STRUCTURES.cpp\n//\n//  Created by Prince  Kumar on 25/06/2020.\n//  Copyright © 2020 Prince  Kumar. All rights re"
  },
  {
    "path": "STL/stack in STL data structure.cpp",
    "chars": 634,
    "preview": "//\n//  DATA STRUCTURES.cpp\n//\n//  Created by Prince  Kumar on 6/06/2020.\n//  Copyright © 2020 Prince  Kumar. All rights "
  }
]

// ... and 12 more files (download for full content)

About this extraction

This page contains the full source code of the Prince-1501/Hello_world-Competiitve-Programming GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 212 files (192.6 KB), approximately 58.1k tokens, and a symbol index with 480 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!