Skip to content

This repository contains a collection of C++ programs covering Object-Oriented Programming (OOP) concepts and Data Structures & Algorithms (DSA).

Notifications You must be signed in to change notification settings

TonyStark-19/Cpp-coding

Repository files navigation

🚀 C++ OOP and DSA Programs Repository

This repository contains a collection of C++ programs covering Object-Oriented Programming (OOP) concepts and Data Structures & Algorithms (DSA). Each program demonstrates specific principles, helping you build a strong foundation in C++ programming. It’s designed to help you master C++ through hands-on coding.


📂 Repository Structure

This repository is organized into multiple folders, each containing various programs related to OOP and DSA.

🏗 Object-Oriented Programming (OOP) Concepts

Programs demonstrating class structure, object creation, templates and much more.

  • Class program - simple class program
  • Destructor - destructor program
  • Parametrized constructor - a type of constructor
  • Shallow vs Deep copy - to understand how shallow and deep copy works
  • Static data member - to understand usage of static data member
  • Student marksheet - student marksheet program using class
  • Templates - to understand usage of templates in c++

Programs related to Static member, friend, and inline functions.

  • Friend function - to understand usage of friend function
  • Inline function - to understand usage of inline function
  • Static member function - to understand usage of static memeber function

Covers single, multilevel, multiple, hierarchical and hybrid inheritance.

  • Hierarchical inheritance - to understand hierarchical inheritance
  • Hybrid Inheritance - to understand hybrid Inheritance
  • Multilevel inheritance - to understand multilevel inheritance
  • Multilevel inheritance 2 - another program using multilevel inheritance
  • Multiple inheritance - to understand multiple inheritance
  • Single inheritance - to understand single inheritance

Examples of function overloading, operator overloading, and runtime polymorphism.

  • Function overriding - to understand the concept of function overriding
  • Operator overloading - Binary Minus (-) Operator
  • Operator overloading - Binary Plus (+) Operator
  • Operator overloading - Equality (==) Operator
  • Operator overloading - Increment (++) Operator
  • Runtime polymorphism - to understand usage of virtual functions

📊 Data Structures & Algorithms (DSA)

Implementation of arrays and solutions to various LeetCode problems with different approaches.

  • 2Sum - leetcode 1
  • 3Sum - leetcode 15 (using hashing)
  • 3Sum 2 - leetcode 15 (using two pointer approach)
  • 4Sum - leetcode 18
  • Aggresive cows - using binary search approach
  • Binary search - using iterative method
  • Binary search 2 - using recursive method
  • Binary search 3 - leetcode 33
  • Book allocation - using binary search approach
  • Bubble sort - bubble sort algorithm
  • Buy and sell - leetcode 121
  • Container with most water - leetcode 21 (brute force)
  • Container with most water 2 - leetcode 21 (using two pointer approach)
  • Diagonal sum in matrix - leetcode 1572
  • Find duplicate - leetcode 287
  • Find missing and repeating value - leetcode 2965
  • Insertion sort - insertion sort algorithm
  • Linear search - linear search algorithm
  • Linear search in matrix - linear search in matrix
  • Majority element - leetcode 169 (brute force)
  • Majority element 2 - leetcode 169 (moore's voting algorithm)
  • Maximum row and column sum - Maximum row and column sum problem
  • Maximum subarray sum - leetcode 53 (brute force)
  • Maximum subarray sum 2 - leetcode 53 (Kadane's algorithm)
  • Merge sorted arrays - leetcode 88
  • Next permutation - leetcode 31
  • Painter's partition - using binary search approach
  • Pair sum - binary search approach
  • Pair sum 2 - two pointer approach
  • Peak index - leetcode 852 (brute force)
  • Peak index 2 - leetcode 852 (optimized)
  • Power function - leetcode 50
  • Product of array - leetcode 238 (brute force)
  • Product of array 2 - leetcode 238 (optimized)
  • Reverse array - to reverse an array
  • Search in 2d matrix - leetcode 74
  • Search in 2d matrix II - leetcode 240
  • Selection sort - selection sort algorithm
  • Single element - leetcode 540 (brute force)
  • Single element 2 - leetcode 540 (binary search)
  • Small and large in array - Small and large element in array
  • Sort colors - leetcode 75 (optimized)
  • Sort colors - leetcode 75 (Dutch national flag algortihm)
  • Spiral matrix - leetcode 54
  • Subarray sum equal k - leetcode 560
  • Sum product in array - sum and product of an array
  • Swap max min in array - to swap max and min elements of an array

Implementation of Linked list and solutions to various LeetCode problems with different approaches.

  • Circular Linked-list - program for circular linked list implementation
  • Copy list with random pointers - leetcode 138
  • Doubly Linked-list - program for doubly linked list implementation
  • Flatten a Multilevel Doubly Linked List - leetcode 430
  • Linked-list intro - program for linked list implementation
  • Linked-list cycle - leetcode 141
  • Linked-list cycle II - leetcode 142
  • Merge two sorted lists - leetcode 21
  • Middle of Linked-list - leetcode 876
  • Reverse Linked-list - leetcode 206
  • Reverse nodes in k group - leetcode 25
  • Swap Nodes in Pairs - leetcode 24

🔹 Stack

Implementation of Stack and solutions to various LeetCode problems with different approaches.

  • Celebrity Problem - the celebrity problem
  • Design Min Stack - leetcode 155
  • Design Min Stack 2 - leetcode 155 (more optimal)
  • Largest Rectangle in Histogram - leetcode 84
  • Next greater element - next greater element problem
  • Next greater element I - leetcode 496
  • Next greater element II - leetcode 503
  • Previous Smaller Element - previous smaller element problem
  • Stack using Linked-list - stack implementation using linked-list
  • Stack using STL - stack implementation using STL library
  • Stack using vectors - stack implementation using vectors
  • Stock span - stock span problem
  • Trapping Rain Water - leetcode 42 (using prefix array)
  • Trapping Rain Water 2 - leetcode 42 (using two pointer approach)
  • Valid Parentheses - leetcode 20

Programs demonstrating recursive problem-solving techniques.

  • Binary search - leetcode 704
  • Combination Sum - leetcode 39
  • Count inversion - using merge sort algorithm
  • Factorial - factorial using recursion
  • Fibonacci - leetcode 509
  • Is array sorted - is array sorted or not using recursion
  • Knights tour - leetcode 2596
  • Merge sort algorithm - merge sort algorithm implementation using recursion
  • N queens - leetcode 51
  • N sum - sum of n values using recursion
  • Palindrome partitioning - leetcode 131
  • Permutations in array - leetcode 46
  • Quick sort algorithm - quick sort algorithm implementation
  • Rat in a maze - rat in a maze problem using recursion
  • Subsets - leetcode 78
  • Subsets II - leetcode 90
  • Sudoku solver - leetcode 37

A collection of pattern-printing programs using loops.

  • Butterfly pattern
  • Floyd triangle pattern
  • Hollow diamond pattern
  • Inverted triangle pattern
  • Pyramid pattern
  • Reverse triangle pattern
  • Square pattern
  • Square pattern 2
  • Triangle pattern
  • Triangle pattern 2

📁 Additional Sections

General C++ programs that don't fit into the above categories.

  • Count primes - to count all prime numbers in a range
  • GCD - gcd program using Euclid's Algorithm
  • Palindrome number - leetcode 9
  • Permutation in a string - leetcode 567
  • Read and Write in a file - to read and write in file using file handling
  • Remove all occurrences - leetcode 1910
  • Reverse integer - leetcode 7
  • Reverse string - leetcode 344
  • Reverse string 2 - to reverse a string directly using reverse function
  • Reverse words in a string - leetcode 151
  • String compression - leetcode 443
  • Valid palindrome - leetcode 125

🔧 Prerequisites

To run the programs in this repository, you need:

  • A C++ compiler (e.g., GCC, MinGW, or Visual Studio).
  • Basic knowledge of C++ programming, OOP principles, and DSA techniques.

About

This repository contains a collection of C++ programs covering Object-Oriented Programming (OOP) concepts and Data Structures & Algorithms (DSA).

Topics

Resources

Stars

Watchers

Forks

Languages