Step-by-Step Approach to learn DSA
➊ Learn One Programming Language
↓
➋ Fundamentals → Time & Space Complexity
↓
➌ Brute Force Algorithms
↓
➍ Basic Data Structures → Array, Linked List
↓
➎ Simple Search Algorithm
↓
➏ Sorting Techniques → Bubble, Selection, Insertion
↓
➐ Slightly Complex Algorithms → Recursion, DnC
↓
➑ Complex Data Structures → Stack, Queue, Tree
DSA Interview Preparation Resources: https://topmate.io/coding/886874
ENJOY LEARNING 👍👍
➊ Learn One Programming Language
↓
➋ Fundamentals → Time & Space Complexity
↓
➌ Brute Force Algorithms
↓
➍ Basic Data Structures → Array, Linked List
↓
➎ Simple Search Algorithm
↓
➏ Sorting Techniques → Bubble, Selection, Insertion
↓
➐ Slightly Complex Algorithms → Recursion, DnC
↓
➑ Complex Data Structures → Stack, Queue, Tree
DSA Interview Preparation Resources: https://topmate.io/coding/886874
ENJOY LEARNING 👍👍
👍4
100+ Practice Questions
❍ C/C++
❍ Python
❍ JavaScript
❍ Java
❍ C#
❍ Golang
➊ Simple Numbers
➀ Find a digit at a specific place in a number
➁ Find count of digits in a number
➂ Find the largest digit
➃ Find the 2nd largest digit
➄ Find the kth largest digit
➅ Find the smallest digit
➆ Find the 2nd smallest digit
➇ Find the kth smallest digit
➈ Find generic root (sum of all digits) of a number
➉ Reverse the digits in a number
➀➀ Rotate the digits in a number
➀➁ Is the number a palindrome?
➀➂ Find sum of 'n' numbers
➀➃ Check if a number is perfect square
➀➄ Find a number in an AP sequence
➀➅ Find a number in a GP sequence
➀➆ Find a number in fibonacci sequence
➀➇ Check number divisibility by 2, 3, 5, 9
➀➈ Check if a number is primary or not
20. Given a number, print all primes smaller than it
➁➀ Check if a number is circular prime or not
➁➁ Find all prime factors of a number
➁➂ Find the GCD of 2 numbers
➁➃ Find the LCM of 2 numbers
➁➄ Find the factorial of a number
➁➅ Find the exponentiation of a number
➋ Unit Conversion
➀ Number Base (Binary, Octal, Hexadecimal, Decimal)
➁ Weight (gram, kg, pound)
➂ Height (cm, m, inch, feet)
➃ Temperature (centigrade, fahrenhite)
➄ Distance (km, mile)
➅ Area (m², km², acre)
➆ Volume (ltr, gallon)
➇ Time (sec, min, hour)
➈ Currency
➌ Calculator
➀ Loan EMI Calculator
➁ Fixed Deposit Returns Calculator
➂ Interest Calculator
➃ BMI Calculator
➄ Item Price (considering tax, discount, shipping)
➅ Tip Calculator
➍ Geometry
➀ Find distance between 2 points
➁ Given 2 sides of a right angle triangle, find the 3rd
➂ Find 3rd angle of a triangle when 2 are given
➃ Area of a triangle when 3 sides are given
➄ Area of a right angle triangle
➅ Perimeter of a Square
➆ Area of a Square
➇ Perimeter of a Rectangle
➈ Area of a Rectangle
➉ Circumference of a Circle
➀➀ Area of a Circle
➀➁ Circumference of a Semi-Circle
➀➂ Area of a Semi-Circle
➀➃ Area of a Ring
➀➄ Circumference of an Ellipse
➀➅ Area of an Ellipse
➀➆ Suface Area of a Sphere
➀➇ Volume of a Sphere
➀➈ Surface Area of a Hemisphere
20. Volume of a Hemisphere
➁➀ Surface area of a Cube
➁➁ Volume of a Cube
➁➂ Surface area of a Cylinder
➁➃ Volume of a Cylinder
➎ Vector
➀ Find Scalar Multiplication of a vector
➁ Find addition/subtraction of vectors
➂ Find magnitude of a vector
➃ Find an unit vector along a given vector
➄ Find dot product of 2 vectors
➅ Find cross product of 2 vectors
➆ Check if 2 vectors are orthogonal
➏ Matrix
➀ Find the determinant of a matrix
➁ Find Scalar Multiplication of a matrix
➂ Find addition/subtraction of matrices
➃ Find the transpose of a matrix
➄ Find if 2 matrices are orthogonal
➅ Find inverse of a 2x2 and 3x3 matrix
➐ Set
➀ Find Union of 2 sets
➁ Find Intersection of 2 sets
➂ Find the Difference of 2 sets
➃ Find the Symmetric Difference of 2 sets
➄ Find if a set is subset/superset of another set
➅ Find if 2 sets are disjoints
➑ Special Numbers
➀ Strong Number
➁ Perfect Number
➂ Armstrong Number
➃ Harshad Number
➄ Kaprekar Number
➅ Lychrel Number
➆ Narcissistic Decimal Number
➇ Lucus Number
➈ Catalan Number
➉ Duck Number
➀➀ Ugly Number
➀➁ Abundant Number
➀➂ Deficient Number
➀➃ Automorphic Number
➀➄ Magic Number
➀➅ Friendly Pair Numbers
➀➆ Neon Number
➀➇ Spy Number
➀➈ Happy Number
20. Sunny Number
➁➀ Disarium Number
➁➁ Pronic Number
➁➂ Trimorphic Number
➁➃ Evil Number
➁➄ Amicable Pairs
❍ C/C++
❍ Python
❍ JavaScript
❍ Java
❍ C#
❍ Golang
➊ Simple Numbers
➀ Find a digit at a specific place in a number
➁ Find count of digits in a number
➂ Find the largest digit
➃ Find the 2nd largest digit
➄ Find the kth largest digit
➅ Find the smallest digit
➆ Find the 2nd smallest digit
➇ Find the kth smallest digit
➈ Find generic root (sum of all digits) of a number
➉ Reverse the digits in a number
➀➀ Rotate the digits in a number
➀➁ Is the number a palindrome?
➀➂ Find sum of 'n' numbers
➀➃ Check if a number is perfect square
➀➄ Find a number in an AP sequence
➀➅ Find a number in a GP sequence
➀➆ Find a number in fibonacci sequence
➀➇ Check number divisibility by 2, 3, 5, 9
➀➈ Check if a number is primary or not
20. Given a number, print all primes smaller than it
➁➀ Check if a number is circular prime or not
➁➁ Find all prime factors of a number
➁➂ Find the GCD of 2 numbers
➁➃ Find the LCM of 2 numbers
➁➄ Find the factorial of a number
➁➅ Find the exponentiation of a number
➋ Unit Conversion
➀ Number Base (Binary, Octal, Hexadecimal, Decimal)
➁ Weight (gram, kg, pound)
➂ Height (cm, m, inch, feet)
➃ Temperature (centigrade, fahrenhite)
➄ Distance (km, mile)
➅ Area (m², km², acre)
➆ Volume (ltr, gallon)
➇ Time (sec, min, hour)
➈ Currency
➌ Calculator
➀ Loan EMI Calculator
➁ Fixed Deposit Returns Calculator
➂ Interest Calculator
➃ BMI Calculator
➄ Item Price (considering tax, discount, shipping)
➅ Tip Calculator
➍ Geometry
➀ Find distance between 2 points
➁ Given 2 sides of a right angle triangle, find the 3rd
➂ Find 3rd angle of a triangle when 2 are given
➃ Area of a triangle when 3 sides are given
➄ Area of a right angle triangle
➅ Perimeter of a Square
➆ Area of a Square
➇ Perimeter of a Rectangle
➈ Area of a Rectangle
➉ Circumference of a Circle
➀➀ Area of a Circle
➀➁ Circumference of a Semi-Circle
➀➂ Area of a Semi-Circle
➀➃ Area of a Ring
➀➄ Circumference of an Ellipse
➀➅ Area of an Ellipse
➀➆ Suface Area of a Sphere
➀➇ Volume of a Sphere
➀➈ Surface Area of a Hemisphere
20. Volume of a Hemisphere
➁➀ Surface area of a Cube
➁➁ Volume of a Cube
➁➂ Surface area of a Cylinder
➁➃ Volume of a Cylinder
➎ Vector
➀ Find Scalar Multiplication of a vector
➁ Find addition/subtraction of vectors
➂ Find magnitude of a vector
➃ Find an unit vector along a given vector
➄ Find dot product of 2 vectors
➅ Find cross product of 2 vectors
➆ Check if 2 vectors are orthogonal
➏ Matrix
➀ Find the determinant of a matrix
➁ Find Scalar Multiplication of a matrix
➂ Find addition/subtraction of matrices
➃ Find the transpose of a matrix
➄ Find if 2 matrices are orthogonal
➅ Find inverse of a 2x2 and 3x3 matrix
➐ Set
➀ Find Union of 2 sets
➁ Find Intersection of 2 sets
➂ Find the Difference of 2 sets
➃ Find the Symmetric Difference of 2 sets
➄ Find if a set is subset/superset of another set
➅ Find if 2 sets are disjoints
➑ Special Numbers
➀ Strong Number
➁ Perfect Number
➂ Armstrong Number
➃ Harshad Number
➄ Kaprekar Number
➅ Lychrel Number
➆ Narcissistic Decimal Number
➇ Lucus Number
➈ Catalan Number
➉ Duck Number
➀➀ Ugly Number
➀➁ Abundant Number
➀➂ Deficient Number
➀➃ Automorphic Number
➀➄ Magic Number
➀➅ Friendly Pair Numbers
➀➆ Neon Number
➀➇ Spy Number
➀➈ Happy Number
20. Sunny Number
➁➀ Disarium Number
➁➁ Pronic Number
➁➂ Trimorphic Number
➁➃ Evil Number
➁➄ Amicable Pairs
👍6🥰3❤2
Git Commands
🛠 git init – Initialize a new Git repository
📥 git clone <repo> – Clone a repository
📊 git status – Check the status of your repository
➕ git add <file> – Add a file to the staging area
📝 git commit -m "message" – Commit changes with a message
🚀 git push – Push changes to a remote repository
⬇️ git pull – Fetch and merge changes from a remote repository
Branching
📌 git branch – List all branches
🌱 git branch <name> – Create a new branch
🔄 git checkout <branch> – Switch to a branch
🔗 git merge <branch> – Merge a branch into the current branch
⚡️ git rebase <branch> – Apply commits on top of another branch
Undo & Fix Mistakes
⏪ git reset --soft HEAD~1 – Undo the last commit but keep changes
❌ git reset --hard HEAD~1 – Undo the last commit and discard changes
🔄 git revert <commit> – Create a new commit that undoes a specific commit
Logs & History
📖 git log – Show commit history
🌐 git log --oneline --graph --all – View commit history in a simple graph
Stashing
📥 git stash – Save changes without committing
🎭 git stash pop – Apply stashed changes and remove them from stash
Remote & Collaboration
🌍 git remote -v – View remote repositories
📡 git fetch – Fetch changes without merging
🕵️ git diff – Compare changes
Don’t forget to react ❤️ if you’d like to see more content like this!
🛠 git init – Initialize a new Git repository
📥 git clone <repo> – Clone a repository
📊 git status – Check the status of your repository
➕ git add <file> – Add a file to the staging area
📝 git commit -m "message" – Commit changes with a message
🚀 git push – Push changes to a remote repository
⬇️ git pull – Fetch and merge changes from a remote repository
Branching
📌 git branch – List all branches
🌱 git branch <name> – Create a new branch
🔄 git checkout <branch> – Switch to a branch
🔗 git merge <branch> – Merge a branch into the current branch
⚡️ git rebase <branch> – Apply commits on top of another branch
Undo & Fix Mistakes
⏪ git reset --soft HEAD~1 – Undo the last commit but keep changes
❌ git reset --hard HEAD~1 – Undo the last commit and discard changes
🔄 git revert <commit> – Create a new commit that undoes a specific commit
Logs & History
📖 git log – Show commit history
🌐 git log --oneline --graph --all – View commit history in a simple graph
Stashing
📥 git stash – Save changes without committing
🎭 git stash pop – Apply stashed changes and remove them from stash
Remote & Collaboration
🌍 git remote -v – View remote repositories
📡 git fetch – Fetch changes without merging
🕵️ git diff – Compare changes
Don’t forget to react ❤️ if you’d like to see more content like this!
👍5
Theoretical Questions for Interviews on Array
1. What is an array?
An array is a data structure consisting of a collection of elements, each identified by at least one array index or key.
2. How do you declare an Array?
Each language has its own way of declaring arrays, but the general idea is similar: defining the type of elements and the number of elements or initializing it directly.
✅ C/C++: int arr[5]; (Declares an array of 5 integers).
✅ Java: int[] arr = new int[5]; (Declares and initializes an array of 5 integers).
✅ Python: arr = [1, 2, 3, 4, 5] (Uses a list, which functions like an array and doesn’t require a fixed size).
✅ JavaScript: let arr = [1, 2, 3, 4, 5]; (Uses arrays without needing a size specification).
✅ C#: int[] arr = new int[5]; (Declares an array of 5 integers).
3. Can an array be resized at runtime?
An array is fixed in size once created. However, in C, you can resize an array at runtime using Dynamic Memory Allocation (DMA) with malloc() or realloc(). Most modern languages have dynamic-sized arrays like vector in C++, list in Python, and ArrayList in Java, which automatically resize.
4. Is it possible to declare an array without specifying its size?
In C/C++, declaring an array without specifying its size is not allowed and causes a compile-time error. However, in C, we can create a pointer and allocate memory dynamically using malloc(). In C++, we can use vectors where we can declare first and then dynamically add elements. In modern languages like Java, Python, and JavaScript, we can declare without specifying the size.
5. What is the time complexity for accessing an element in an array?
The time complexity for accessing an element in an array is O(1), as it can be accessed directly using its index.
6. What is the difference between an array and a linked list?
An array is a static data structure, while a linked list is a dynamic data structure. Raw arrays have a fixed size, and elements are stored consecutively in memory, while linked lists can grow dynamically and do not require contiguous memory allocation. Dynamic-sized arrays allow flexible size, but the worst-case time complexity for insertion/deletion at the end becomes more than O(1). With a linked list, we get O(1) worst-case time complexity for insertion and deletion.
7. How would you find out the smallest and largest element in an array?
The best approach is iterative (linear search), while other approaches include recursive and sorting.
Iterative method
Algorithm:
1. Initialize two variables:
small = arr[0] (first element as the smallest).
large = arr[0] (first element as the largest).
2. Traverse through the array from index 1 to n-1.
3. If arr[i] > large, update large = arr[i].
4. If arr[i] < small, update small = arr[i].
5. Print the values of small and large.
C++ Code Implementation
#include <iostream>
using namespace std;
void findMinMax(int arr[], int n) {
int small = arr[0], large = arr[0];
for (int i = 1; i < n; i++) {
if (arr[i] > large)
large = arr[i];
if (arr[i] < small)
small = arr[i];
}
cout << "Smallest element: " << small << endl;
cout << "Largest element: " << large << endl;
}
int main() {
int arr[] = {7, 2, 9, 4, 1, 5};
int n = sizeof(arr) / sizeof(arr[0]);
findMinMax(arr, n);
return 0;
}
8. What is the time complexity to search in an unsorted and sorted array?
✅ Unsorted Array: The time complexity for searching an element in an unsorted array is O(n), as we may need to check every element.
✅ Sorted Array: The time complexity for searching an element in a sorted array is O(log n) using binary search.
🔹 O(log n) takes less time than O(n), whereas O(n log n) takes more time than O(n).
Free Coding Interview Resources: https://whatsapp.com/channel/0029VammZijATRSlLxywEC3X
1. What is an array?
An array is a data structure consisting of a collection of elements, each identified by at least one array index or key.
2. How do you declare an Array?
Each language has its own way of declaring arrays, but the general idea is similar: defining the type of elements and the number of elements or initializing it directly.
✅ C/C++: int arr[5]; (Declares an array of 5 integers).
✅ Java: int[] arr = new int[5]; (Declares and initializes an array of 5 integers).
✅ Python: arr = [1, 2, 3, 4, 5] (Uses a list, which functions like an array and doesn’t require a fixed size).
✅ JavaScript: let arr = [1, 2, 3, 4, 5]; (Uses arrays without needing a size specification).
✅ C#: int[] arr = new int[5]; (Declares an array of 5 integers).
3. Can an array be resized at runtime?
An array is fixed in size once created. However, in C, you can resize an array at runtime using Dynamic Memory Allocation (DMA) with malloc() or realloc(). Most modern languages have dynamic-sized arrays like vector in C++, list in Python, and ArrayList in Java, which automatically resize.
4. Is it possible to declare an array without specifying its size?
In C/C++, declaring an array without specifying its size is not allowed and causes a compile-time error. However, in C, we can create a pointer and allocate memory dynamically using malloc(). In C++, we can use vectors where we can declare first and then dynamically add elements. In modern languages like Java, Python, and JavaScript, we can declare without specifying the size.
5. What is the time complexity for accessing an element in an array?
The time complexity for accessing an element in an array is O(1), as it can be accessed directly using its index.
6. What is the difference between an array and a linked list?
An array is a static data structure, while a linked list is a dynamic data structure. Raw arrays have a fixed size, and elements are stored consecutively in memory, while linked lists can grow dynamically and do not require contiguous memory allocation. Dynamic-sized arrays allow flexible size, but the worst-case time complexity for insertion/deletion at the end becomes more than O(1). With a linked list, we get O(1) worst-case time complexity for insertion and deletion.
7. How would you find out the smallest and largest element in an array?
The best approach is iterative (linear search), while other approaches include recursive and sorting.
Iterative method
Algorithm:
1. Initialize two variables:
small = arr[0] (first element as the smallest).
large = arr[0] (first element as the largest).
2. Traverse through the array from index 1 to n-1.
3. If arr[i] > large, update large = arr[i].
4. If arr[i] < small, update small = arr[i].
5. Print the values of small and large.
C++ Code Implementation
#include <iostream>
using namespace std;
void findMinMax(int arr[], int n) {
int small = arr[0], large = arr[0];
for (int i = 1; i < n; i++) {
if (arr[i] > large)
large = arr[i];
if (arr[i] < small)
small = arr[i];
}
cout << "Smallest element: " << small << endl;
cout << "Largest element: " << large << endl;
}
int main() {
int arr[] = {7, 2, 9, 4, 1, 5};
int n = sizeof(arr) / sizeof(arr[0]);
findMinMax(arr, n);
return 0;
}
8. What is the time complexity to search in an unsorted and sorted array?
✅ Unsorted Array: The time complexity for searching an element in an unsorted array is O(n), as we may need to check every element.
✅ Sorted Array: The time complexity for searching an element in a sorted array is O(log n) using binary search.
🔹 O(log n) takes less time than O(n), whereas O(n log n) takes more time than O(n).
Free Coding Interview Resources: https://whatsapp.com/channel/0029VammZijATRSlLxywEC3X
👍5
🚀 Roadmap to Become a Software Architect 👨💻
📂 Programming & Development Fundamentals
∟📂 Master One or More Programming Languages (Java, C#, Python, etc.)
∟📂 Learn Data Structures & Algorithms
∟📂 Understand Design Patterns & Best Practices
📂 Software Design & Architecture Principles
∟📂 Learn SOLID Principles & Clean Code Practices
∟📂 Master Object-Oriented & Functional Design
∟📂 Understand Domain-Driven Design (DDD)
📂 System Design & Scalability
∟📂 Learn Microservices & Monolithic Architectures
∟📂 Understand Load Balancing, Caching & CDNs
∟📂 Dive into CAP Theorem & Event-Driven Architecture
📂 Databases & Storage Solutions
∟📂 Master SQL & NoSQL Databases
∟📂 Learn Database Scaling & Sharding Strategies
∟📂 Understand Data Warehousing & ETL Processes
📂 Cloud Computing & DevOps
∟📂 Learn Cloud Platforms (AWS, Azure, GCP)
∟📂 Understand CI/CD & Infrastructure as Code (IaC)
∟📂 Work with Containers & Kubernetes
📂 Security & Performance Optimization
∟📂 Master Secure Coding Practices
∟📂 Learn Authentication & Authorization (OAuth, JWT)
∟📂 Optimize System Performance & Reliability
📂 Project Management & Communication
∟📂 Work with Agile & Scrum Methodologies
∟📂 Collaborate with Cross-Functional Teams
∟📂 Improve Technical Documentation & Decision-Making
📂 Real-World Experience & Leadership
∟📂 Design & Build Scalable Software Systems
∟📂 Contribute to Open-Source & Architectural Discussions
∟📂 Mentor Developers & Lead Engineering Teams
📂 Interview Preparation & Career Growth
∟📂 Solve System Design Challenges
∟📂 Master Architectural Case Studies
∟📂 Network & Apply for Software Architect Roles
✅ Get Hired as a Software Architect
React "❤️" for More 👨💻
📂 Programming & Development Fundamentals
∟📂 Master One or More Programming Languages (Java, C#, Python, etc.)
∟📂 Learn Data Structures & Algorithms
∟📂 Understand Design Patterns & Best Practices
📂 Software Design & Architecture Principles
∟📂 Learn SOLID Principles & Clean Code Practices
∟📂 Master Object-Oriented & Functional Design
∟📂 Understand Domain-Driven Design (DDD)
📂 System Design & Scalability
∟📂 Learn Microservices & Monolithic Architectures
∟📂 Understand Load Balancing, Caching & CDNs
∟📂 Dive into CAP Theorem & Event-Driven Architecture
📂 Databases & Storage Solutions
∟📂 Master SQL & NoSQL Databases
∟📂 Learn Database Scaling & Sharding Strategies
∟📂 Understand Data Warehousing & ETL Processes
📂 Cloud Computing & DevOps
∟📂 Learn Cloud Platforms (AWS, Azure, GCP)
∟📂 Understand CI/CD & Infrastructure as Code (IaC)
∟📂 Work with Containers & Kubernetes
📂 Security & Performance Optimization
∟📂 Master Secure Coding Practices
∟📂 Learn Authentication & Authorization (OAuth, JWT)
∟📂 Optimize System Performance & Reliability
📂 Project Management & Communication
∟📂 Work with Agile & Scrum Methodologies
∟📂 Collaborate with Cross-Functional Teams
∟📂 Improve Technical Documentation & Decision-Making
📂 Real-World Experience & Leadership
∟📂 Design & Build Scalable Software Systems
∟📂 Contribute to Open-Source & Architectural Discussions
∟📂 Mentor Developers & Lead Engineering Teams
📂 Interview Preparation & Career Growth
∟📂 Solve System Design Challenges
∟📂 Master Architectural Case Studies
∟📂 Network & Apply for Software Architect Roles
✅ Get Hired as a Software Architect
React "❤️" for More 👨💻
👍4❤1