Skip to content
  • General
  • Programming
  • DS & Algo
  • System Design
  • Interview Questions
  • Home
  • YouTube
  • About
  • Contact
Learn to Code and Code to Learn

Learn to Code and Code to Learn

Your Journey to Code Mastery

  • General
    • Setup
  • Programming
    • C++
    • C++-11
    • c++-14
    • Python
  • DS & Algo
    • DS
    • Algo
      • Competitive Programming
        • Leetcode Problems
  • System Design
    • Design Pattern
    • SOLID Principle
  • Interview Questions
    • C++
    • Company Wise
  • Toggle search form

Category: GFG PTOD

GFG PTOD | 30 Jan | N-Queen Problem | Hard | Backtracking

Posted on January 30, 2025January 30, 2025 By thecodepathshala No Comments on GFG PTOD | 30 Jan | N-Queen Problem | Hard | Backtracking
void solve(int colm, int n, vector<bool> &col, vector<bool> &ldiag, vector<bool> &rdiag, vector<vector<int>> &ans, vector<int> &res) {
        for(int i=0; i<n; i++) {
            if(colm == n) {
                ans.push_back(res);
                return;
            }
            if(!col[i] && !ldiag[colm-i + n-1] && !rdiag[i+colm]) {
                res.push_back(i+1);
                col[i] = true;
                ldiag[colm-i+n-1] = true;
                rdiag[i+colm] = true;
                solve(colm+1, n, col, ldiag, rdiag, ans, res);
                
                res.pop_back();
                col[i] = false;
                ldiag[colm-i+n-1] = false;
                rdiag[i+colm] = false;
                
            }
        }
        
    }
    vector<vector<int>> nQueen(int n) {
        // code here
        vector<bool>col(n, false);
        vector<bool>ldiag(2*n-1, false);
        vector<bool>rdiag(2*n-1, false);
        vector<vector<int>> ans;
        vector<int> res;
        solve(0, n, col, ldiag, rdiag, ans, res);
        return ans;
    }
Competitive Programming, DS & Algo, GFG, GFG PTOD

GFG PTOD | 29 Jan | Implement Pow

Posted on January 29, 2025January 29, 2025 By thecodepathshala No Comments on GFG PTOD | 29 Jan | Implement Pow
double power(double b, int e) {
        // code here
        int n = abs(e);
        double res = 1.0;
        while(n>0) {
            if(n%2 == 0) {
                b *=b;
                n=n/2;
            } else {
                res *= b;
                n--;
            }
        }
        if(e<0) res = double(1.0)/res;
        return res;
    }
Competitive Programming, DS & Algo, GFG, GFG PTOD

GFG PTOD | 28 Jan | Permutations of a String

Posted on January 28, 2025January 28, 2025 By thecodepathshala No Comments on GFG PTOD | 28 Jan | Permutations of a String
void helper(int i, int n, string &s, unordered_set<string> &st, string &cur) {
        if(cur.size() == n) {
            st.insert(cur);
            return;
        }
        for(int j=i; j<n; j++) {
            swap(s[i], s[j]);
            cur.push_back(s[i]);
            helper(i+1, n, s, st, cur);
            cur.pop_back();
            swap(s[i], s[j]);
        }
    }
    vector<string> findPermutation(string &s) {
        // Code here there
        unordered_set<string> st;
        string cur;
        helper(0, s.size(), s, st, cur);
        vector<string> res(st.begin(), st.end());
        return res;
    }
Competitive Programming, DS & Algo, GFG, GFG PTOD

GFG PTOD | 26 Jan | Remove loop in Linked List

Posted on January 25, 2025January 25, 2025 By thecodepathshala No Comments on GFG PTOD | 26 Jan | Remove loop in Linked List
void removeLoop(Node* head) {
        // code here
        Node* slow = head, *fast = head;
        while(fast && fast->next) {
            slow = slow->next;
            fast = fast->next->next;
            if(slow == fast) {
                slow = head;
                // check if fast and slow pointer at head node
                if(fast == slow) {
                    while(fast->next != slow)
                        fast = fast->next;
                }
                else {
                   while(slow->next !=fast->next) {
                        slow = slow->next;
                        fast = fast->next;
                    } 
                }
                
                fast->next = NULL;
            }
        }
    }
Competitive Programming, DS & Algo, GFG, GFG PTOD

GFG PTOD | 25 Jan | Find the first node of loop in linked list

Posted on January 25, 2025January 25, 2025 By thecodepathshala No Comments on GFG PTOD | 25 Jan | Find the first node of loop in linked list
Node* findFirstNode(Node* head) {
        // your code here
        Node* slow = head, *fast = head;
        while(fast && fast->next) {
            slow = slow->next;
            fast = fast->next->next;
            if(slow == fast) {
                slow = head;
                while(slow!=fast) {
                    slow = slow->next;
                    fast = fast->next;
                }
                return slow;
            }
        }
        return NULL;
    }
Competitive Programming, DS & Algo, GFG, GFG PTOD

GFG PTOD | 24 Jan | Detect Loop in linked list

Posted on January 25, 2025January 25, 2025 By thecodepathshala No Comments on GFG PTOD | 24 Jan | Detect Loop in linked list
// Function to check if the linked list has a loop.
    bool detectLoop(Node* head) {
        // your code here
        Node *slow=head, *fast=head;
        while(fast && fast->next) {
            slow = slow->next;
            fast = fast->next->next;
            if(slow == fast) return true;
        }
        return false;
    }
Competitive Programming, DS & Algo, GFG, GFG PTOD

GFG PTOD | 23 Jan | Clone List with Next and Random

Posted on January 25, 2025January 25, 2025 By thecodepathshala No Comments on GFG PTOD | 23 Jan | Clone List with Next and Random
Node *cloneLinkedList(Node *head) {
        // Write your code here
        if(head == NULL) return head;
        Node *cur = head;
        // Step 1: create new node and make a link from first to create map
        while(cur) {
            Node *newNode = new Node(cur->data);
            newNode->next = cur->next;
            cur->next = newNode;
            cur = newNode->next;
        }
        // Step 2: Assign random pointer to head2
        cur = head;
        Node *head2 = cur->next;
        while(cur!=NULL) {
            if(cur->random == NULL) cur->next->random = NULL;
            else cur->next->random = cur->random->next;
            cur = cur->next->next;
        }
        //Step 3: Make proper link of head and head2 and return head2
        cur=head;
        while(cur) {
            Node *tmp = cur->next;
            cur->next = tmp->next;
            if(tmp->next) tmp->next = tmp->next->next;
            cur=cur->next;
        }
        return head2;
    }
Competitive Programming, DS & Algo, GFG, GFG PTOD

GFG PTOD | 25 Jan | Find the first node of loop in linked list

Posted on January 25, 2025January 25, 2025 By thecodepathshala No Comments on GFG PTOD | 25 Jan | Find the first node of loop in linked list
Node* findFirstNode(Node* head) {
        // your code here
        Node* slow = head, *fast = head;
        while(fast && fast->next) {
            slow = slow->next;
            fast = fast->next->next;
            if(slow == fast) {
                slow = head;
                while(slow!=fast) {
                    slow = slow->next;
                    fast = fast->next;
                }
                return slow;
            }
        }
        return NULL;
    }
Competitive Programming, DS & Algo, GFG, GFG PTOD

GFG PTOD | 22 Jan 2025 | Add Number Linked Lists

Posted on January 22, 2025January 22, 2025 By thecodepathshala No Comments on GFG PTOD | 22 Jan 2025 | Add Number Linked Lists
class Solution {
  public:
    Node* reverseList(struct Node* head) {
       struct Node* cur = head, *prev = NULL, *next = NULL;
        while(cur != NULL) {
            next = cur->next;
            cur->next = prev;
            prev = cur;
            cur = next;
        }
        return prev;
    }
    
    Node* removeZero(struct Node* head) {
        while(head != NULL && head->data == 0)
            head = head->next;
        return head;
    }
    
    Node* addTwoLists(Node* num1, Node* num2) {
        // code here
        num1 = removeZero(num1);
        num2 = removeZero(num2);
        num1 = reverseList(num1);
        num2 = reverseList(num2);
        Node *ret = NULL, *cur=NULL;
        int carry = 0;
        
        while(num1 || num2 || carry != 0) {
            int sum = carry;
            if(num1) {
                sum += num1->data;
                num1 = num1->next;
            }
            if(num2) {
                sum += num2->data;
                num2 = num2->next;
            }
            carry = sum/10;
            Node *tmp = new Node(sum % 10);
            if(ret == NULL) {
                ret = tmp;
                cur = tmp;
            } else {
                cur->next = tmp;
                cur = cur->next;
            }
        }
        return reverseList(ret);
    }
};
Competitive Programming, DS & Algo, GFG, GFG PTOD

GFG PTOD | 21 Jan 2025 | Linked List Group Reverse

Posted on January 21, 2025January 21, 2025 By thecodepathshala No Comments on GFG PTOD | 21 Jan 2025 | Linked List Group Reverse

Recursive Solution : Iterative Solution :

Competitive Programming, DS & Algo, GFG, GFG PTOD

Posts navigation

Previous 1 2 3 4 … 7 Next

Archives

  • August 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • August 2024
  • April 2024
  • March 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • September 2023
  • February 2023
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021

Categories

  • Algo
  • Array in C
  • C Programming
  • C++
  • C++
  • Company Wise
  • Competitive Programming
  • Design Pattern
  • DS
  • DS & Algo
  • Fast and Slow Pointer
  • fixed size sliding window
  • General
  • GFG
  • GFG PTOD
  • Interview Questions
  • Leetcode Problems
  • Leetcode PTOD
  • Leetcode Top Interview 150
  • LLD
  • Low-level design
  • Mastering in C programming (Crash Course)
  • Programming
  • Roadmap
  • Setup
  • Setup
  • sliding window
  • SOLID Principle
  • STL
  • string in c
  • System Design
  • Top X

Tags

algorithm array bactracking basic c++ coding interview C Programming Crash Course data structure and algorithm design pattern dsa easy Fixed size sliding window fubctions GFD gfg GFG PTOD hard jump game LC PTOD leetcode Leetcode PTOD Leetcode Top Interview 150 LLD loop loops Low-level design Mastering C Programming in 15 Days matrix medium recursion rotate array searching&sorting sliding window solid STL string string in c sunction in c system design Template in C++ Top Top 20 coding patterns to master MAANG Interview Top interview 150

Database Sharding #interview #shorts #ytshorts #apple #google #facebook #meta #amazon #softwareengineer 

what is database Sharding 
when database Sharding
Database Sharding #interview #shorts #ytshorts #apple #google #facebook #meta #amazon #software
Use of CDN | what is CDN #cdn #systemdesign #interview #shorts #google #apple #meta #amazon #adobe

content delivery network 
what is cdn
what is the use of cdn
Use of CDN | what is CDN #cdn #systemdesign #interview #shorts #google #apple #meta #amazon #adobe
Horizontal vs Vertical Scaling #systemdesign #google #microsoft #interview #shorts #apple #FAANG

Tags:

horizontal vs vertical scaling, vertical vs horizontal scaling, horizontal scaling vs vertical scaling, horizontal vs vertical scaling pros and cons, vertical scaling vs horizontal scaling, horizontal scaling vs vertical scaling in aws, horizontal vs vertical scaling in cloud computing, horizontal and vertical scaling, horizontal vs vertical, horizontal and vertical scaling in cloud computing, difference between horizontal and vertical scaling, diagonal scaling vs horizontal scaling


#Scalability #HorizontalScaling #VerticalScaling #SystemArchitecture #Computing #technologynews #HorizontalScaling
#VerticalScaling
#Scalability
#ScaleOut
#ScaleUp
#SystemScaling
#DistributedSystems
#InfrastructureScaling
#CloudScaling
#ResourceScaling
#ScaleOut
#DistributedSystems
#LoadBalancing
#CloudScaling
#Scalability
#HorizontalScalingVsVerticalScaling
#HorizontalScalingExplained
#Elasticity
#DistributedComputing
#SystemArchitecture
#HighAvailability
#FaultTolerance
#ScalingStrategies
#InfrastructureScaling
Horizontal vs Vertical Scaling #systemdesign #google #microsoft #interview #shorts #apple #FAANG
😇why Instagram load fast❓⁉️ #Instagram #interview #apple #iit #microsoft
😇why Instagram load fast❓⁉️ #Instagram #interview #apple #iit #microsoft
Load balancer in 30 second #shorts #youtubeshorts #interview #hld #systemdesign #iit #google #apple
Real life example | Abstract factory | Design pattern #designpatterns #lowleveldesign #interview
Advantage of Abstract factory design pattern #interview #lld #google #apple #meta #facebook
Abstract factory design pattern | what? Why? How? #interview #lld #google #apple #meta #facebook
Master Abstract Factory Design Pattern in C++ | Real-World Examples & Code Explanation

In this video, we break down the Abstract Factory Design Pattern in C++ step-by-step. You’ll learn:
✅ What is Abstract Factory Pattern
✅ When & why to use it in C++
✅ UML diagram explanation
✅ Real-world examples for better understanding
✅ Complete C++ code implementation

Whether you’re preparing for FAANG interviews, learning Design Patterns, or improving your Object-Oriented Programming skills, this tutorial will help you write clean, scalable, and maintainable C++ code.

Keywords:
abstract factory c++, abstract factory design pattern c++, abstract factory design pattern example, creational design patterns in c++, design patterns in c++ with examples, faang interview preparation, c++ oops concepts
abstract factory pattern, c programming, design patterns in c, object oriented design, system architecture, software design, c language tutorial, creational patterns, software engineering, c programming tutorial, factory method pattern, design principles, object creation, software development, programming concepts
master abstract factory design pattern in c,
abstract factory design pattern php,
abstract factory design pattern c#,
abstract factory design pattern vs factory pattern,
abstract factory design pattern js,
abstract factory design pattern c++,
abstract factory design pattern example,
factory and abstract factory design pattern in java,
factory method design pattern php,
abstract factory and factory design pattern,
factory pattern and abstract factory pattern,
abstract factory design pattern example c#,
java abstract factory design pattern,
abstract factory method design pattern,
abstract factory design pattern java,
abstract factory design pattern example java,
abstract factory design pattern typescript,
abstract factory design pattern in java,
abstract factory design pattern in c#,
abstract factory design patterns in java,
factory pattern design pattern,
abstract factory design pattern python

#Cpp #DesignPatterns #AbstractFactory #Programming #codewithme 
#masterabstractfactorydesignpatterninc++ #abstractfactorydesignpatterninc++ #masterabstractfactorydesignpatterninc++hindi #masterabstractfactorydesignpatterninc++and #masterabstractfactorydesignpatterninc++andc
Master Abstract Factory Design Pattern in C++ | Real-World Examples & Code Explanation
Load More... Subscribe

Recent Posts

  • Palindrome Linked List
  • Find the Duplicate Number
  • Remove Nth Node From End of List
  • Linked List Cycle II
  • Decode the string | GFG PTOD | 01 Mar| Medium level | STACK

    Recent Comments

    1. reebjnhzey on GFG PTOD | 23 Feb | Next Greater Element | Medium level | STACK
    2. 서울여성전용마사지 on C program to check Leap Year
    3. http://boyarka-inform.com/ on C program to enter basic salary and calculate gross salary of an employee
    4. Denny on C program to enter basic salary and calculate gross salary of an employee
    5. Cabanon Eco on C program to check Leap Year

    Copyright © 2025 Learn to Code and Code to Learn.

    Powered by PressBook Blog WordPress theme