Sep 27, 2025 · 3 min read · 1) Detect a cycle in graph #include <bits/stdc++.h> using namespace std; struct Edge { int src, dest; }; struct Graph { int V, E; vector<Edge> edges; }; // Find the root parent of a node (with path compression) int find(vector<int>& pa...
Join discussion
Sep 23, 2025 · 4 min read · 1) Basic about c++ string char str[] = "Geeks"; string string_name = "Sample String"; // Internal Representation: String characters are internally stored as integers. This means: Characters like 'A' to 'Z' are mapped to integer values 65 to 90. Char...
Join discussion
Sep 1, 2025 · 6 min read · Properties of matrix A matrix represents a collection of numbers arranged in order of rows and columns. It is necessary to enclose the elements of a matrix in parentheses or brackets. A matrix with 9 elements is shown below: The above Matrix M ha...
Join discussion
Aug 31, 2025 · 8 min read · Range sum queries using prefix sum Description : We are given an Array of n integers, We are given q queries having indices l and r . We have to find out sum between the given range of indices. Input [4, 5, 3, 2, 5] 3 0 3 2 4 1 3 Output 14 (4+5+3+...
Join discussion
Aug 31, 2025 · 7 min read · Working of vector and list STL. //vector (Implemented as a dynamic array, storing elements in contiguous memory locations.) // C++ program to illustrate the above functions #include <iostream> #include <vector> using namespace std; int main() ...
Join discussion
Aug 31, 2025 · 3 min read · 1) Modular arithmetic #include <bits/stdc++.h> using namespace std; // Function for modular addition int modAdd(int a, int b, int m) { return ((a % m) + (b % m)) % m; } // Function for modular subtraction int modSub(int a, int b, int m) { r...
Join discussion