Disjoint Set(level-3 )1) Kruskal Algorithm to find minimum spanning tree #include <bits/stdc++.h> using namespace std; // -------- DSU Implementation -------- class DSU { vector<int> parent, rank; public: DSU(int n) { parent.resize(n); rank.resize...Sep 27, 2025·2 min read
Arrays (Level-3)Trapping rainwater // C++ program to find maximum amount of water that can // be trapped within given set of bars. #include <bits/stdc++.h> using namespace std; int findWater(int arr[], int n) { // left[i] contains height of tallest bar to the ...Aug 31, 2025·4 min read
Arrays (Level-2)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+...Aug 31, 2025·8 min read