en
Feedback
Codeforces|Leetcode|Codechef free solutions

Codeforces|Leetcode|Codechef free solutions

Open in Telegram

Free codeforces, Codechef, Leetcode solutions are available 😍😍😍😍😍😍 Helped More than 200+ students to crack coding round in 2022 and helped placed them in Good companies. 🥳🥳🥳🤩🤩🤩 Dm @Cpsoln if you want help in coding round.

Show more
4 317
Subscribers
No data24 hours
-137 days
-5230 days
Posts Archive
#include <iostream> using namespace std; int main() { // your code goes here int t; cin>>t; while(t--) { int x; cin>>x; if(x<=3) cout<<"bronze"<<"\n"; else if(x>3 && x<=6) cout<<"silver"<<"\n"; else cout<<"gold"<<"\n"; } return 0; } Donation Rewards

Since your placement and intern session is coming 🤓🤓 So don't miss any opportunity in this recession😇😇😇😇 📌📌📌📌📌📌📌
+2
Since your placement and intern session is coming 🤓🤓 So don't miss any opportunity in this recession😇😇😇😇 📌📌📌📌📌📌📌📌📌📌📌📌 No scam No fraud because we are not like other telegram channels. If you want help in coding round of any company then Dm @Cpsoln and book your slot ✅✅✅✅

Uploaded all the codes for free ❤❤🥺🥳
Anonymous voting

#include <iostream> #include <vector> #include <algorithm> using namespace std; // Segment tree node struct Node {     int zeros;     int ones; }; // Function to merge two nodes Node mergeNodes(const Node& left, const Node& right) {     Node merged;     merged.zeros = left.zeros + right.zeros;     merged.ones = left.ones + right.ones;     return merged; } // Function to build the segment tree void buildSegmentTree(vector<Node>& tree, const vector<int>& arr, int node, int start, int end) {     if (start == end) {         if (arr[start] == 0) {             tree[node].zeros = 1;             tree[node].ones = 0;         } else {             tree[node].zeros = 0;             tree[node].ones = 1;         }     } else {         int mid = (start + end) / 2;         buildSegmentTree(tree, arr, 2 * node, start, mid);         buildSegmentTree(tree, arr, 2 * node + 1, mid + 1, end);         tree[node] = mergeNodes(tree[2 * node], tree[2 * node + 1]);     } } // Function to update the segment tree void updateSegmentTree(vector<Node>& tree, int node, int start, int end, int index, int value) {     if (start == end) {         if (value == 0) {             tree[node].zeros = 1;             tree[node].ones = 0;         } else {             tree[node].zeros = 0;             tree[node].ones = 1;         }     } else {         int mid = (start + end) / 2;         if (index >= start && index <= mid) {             updateSegmentTree(tree, 2 * node, start, mid, index, value);         } else {             updateSegmentTree(tree, 2 * node + 1, mid + 1, end, index, value);         }         tree[node] = mergeNodes(tree[2 * node], tree[2 * node + 1]);     } } // Function to query the segment tree for the number of ones and zeros in a range Node querySegmentTree(const vector<Node>& tree, int node, int start, int end, int l, int r) {     if (start > r || end < l) {         Node nullNode;         nullNode.zeros = 0;         nullNode.ones = 0;         return nullNode;     }     if (l <= start && end <= r) {         return tree[node];     }     int mid = (start + end) / 2;     Node left = querySegmentTree(tree, 2 * node, start, mid, l, r);     Node right = querySegmentTree(tree, 2 * node + 1, mid + 1, end, l, r);     return mergeNodes(left, right); } // Function to find the minimum change number after which at least one segment becomes beautiful int findBeautifulSegment(const vector<int>& arr, const vector<pair<int, int>>& segments, const vector<int>& changes) {     int n = arr.size();     vector<Node> tree(4 * n);     buildSegmentTree(tree, arr, 1, 0, n - 1);     for (int i = 0; i < changes.size(); i++) {         int index = changes[i] - 1;         updateSegmentTree(tree, 1, 0, n - 1, index, 1);         for (const auto& segment : segments) {             int l = segment.first - 1;             int r = segment.second - 1;             Node result = querySegmentTree(tree, 1, 0, n - 1, l, r);             if (result.ones > result.zeros) {                 return i + 1;             }         }     }     return -1; } int main() {     int t;     cin >> t;     while (t--) {         int n, m;         cin >> n >> m;         vector<int> arr(n, 0);         vector<pair<int, int>> segments(m);         for (int i = 0; i < m; i++) {             int l, r;             cin >> l >> r;             segments[i] = make_pair(l, r);         }         int q;         cin >> q;         vector<int> changes(q);         for (int i = 0; i < q; i++) {             cin >> changes[i];         }         int result = findBeautifulSegment(arr, segments, changes);         cout << result << endl;     }     return 0; }

Codeforces D 🥳🥳🥳

#include <iostream> #include <vector> using namespace std; vector<int> leaf; void dfs(int u, int p, vector<vector<int>>& adj) { for (int v : adj[u]) { if (v != p) { dfs(v, u, adj); leaf[u] += leaf[v]; } } if (leaf[u] == 0) { leaf[u] = 1; } } int main() { int T; cin >> T; while (T--) { int n; cin >> n; vector<vector<int>> adj(n); for (int i = 0; i < n - 1; i++) { int u, v; cin >> u >> v; adj[u - 1].push_back(v - 1); adj[v - 1].push_back(u - 1); } leaf.assign(n, 0); dfs(0, -1, adj); int Q; cin >> Q; while (Q--) { int u, v; cin >> u >> v; u--; // Adjusting to 0-based indexing v--; cout << leaf[u] * leaf[v] << endl; } }     return 0; }

Codeforces B guys ❤❤❤

#include <iostream> #include<bits/stdc++.h> using namespace std; #define int long long void sol(){             int n;     cin>>n;    //   int a[n];   vector<int> a;     int count=0,ans=0;     for(int i=0;i<n;i++){       int x;       cin>>x;       if(x==0) continue;       a.push_back(x);       count+=abs(x);     //   cout<<abs(x)<<" ";   } //   cout<<endl;    n = a.size(); int f=0; for(auto val:a){     if(val<0){         if(f==0){             ans++;             f=1;         }     }     else{         f=0;     } } cout<<count<<" "<<ans<<endl;         return ; } signed main(){     int t;     cin>>t;     while(t--){         sol();     }         return 0; }

Codeforces C

#include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define loop(n) for(long long i=0;i<n;i++) #define rloop(n) for(long long i=n-1;i>=0;i--) signed main(){       ios::sync_with_stdio(false);       cin.tie(nullptr);       #ifndef ONLINE_JUDGE         freopen("input.txt","r",stdin);         freopen("output1.txt","w",stdout);        #endif int test_cases; cin>>test_cases; while(test_cases--){ ll n; cin>>n;     ll sum=0;   while(n){     sum+=n;     n/=2;   }   cout<<sum<<"\n"; }     return 0; }

Codeforces A 🥳🥳🥳❤❤

#include <iostream> #include<bits/stdc++.h> using namespace std; #define int long long void sol(){             int n;     cin>>n;         int a[n];         for(auto &x:a) cin>>x;     sort(a,a+n);         int count=0;     for(int i=0;i<n/2;i++){         count+=abs(a[i]-a[n-i-1]);     }             cout<<count<<endl;                 return ; } signed main(){     int t;     cin>>t;     while(t--){         sol();     }         return 0; }

Codeforces C 🥳🥳🥳🥳🥳

#include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define loop(n) for(long long i=0;i<n;i++) #define rloop(n) for(long long i=n-1;i>=0;i--) signed main(){       ios::sync_with_stdio(false);       cin.tie(nullptr);       #ifndef ONLINE_JUDGE         freopen("input.txt","r",stdin);         freopen("output1.txt","w",stdout);        #endif int test_cases; cin>>test_cases; while(test_cases--){ ll n; cin>>n;     ll sum=0;   while(n){     sum+=n;     n/=2;   }   cout<<sum<<"\n"; }     return 0; }

We will upload the solutions soon Till then don't buy

Share the channel guys Codeforces div 3 solutions will be available for free Join @contestsolution

Thanks guys for 4000 subscribers ❤❤❤🥳🥳🥳
Thanks guys for 4000 subscribers ❤❤❤🥳🥳🥳

If you refer your friends for OA you will get 50Rs discount Dm @Cpsoln

Since your placement and intern session is coming 🤓🤓 So don't miss any opportunity in this recession😇😇😇😇 📌📌📌📌📌📌📌
+2
Since your placement and intern session is coming 🤓🤓 So don't miss any opportunity in this recession😇😇😇😇 📌📌📌📌📌📌📌📌📌📌📌📌 No scam No fraud because we are not like other telegram channels. If you want help in coding round of any company then Dm @Cpsoln and book your slot ✅✅✅✅