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
class Solution { public:     int minimizeSum(vector& nums) {                  int n=nums.size();                  sort(nums.begin(),nums.end());                 return min({nums[n-1]-nums[0],nums[n-1]-nums[2],nums[n-3]-nums[0],nums[n-2]-nums[1]});              } };//b

Leetcode A in cpp

class Solution { public:     int minMaxDifference(int num) {         std::string num_str = std::to_string(num);     int max_val = num;     int min_val = num;     for (int i = 0; i < 10; i++) {         for (int j = 0; j < 10; j++) {             std::string new_num_str = num_str;             std::replace(new_num_str.begin(), new_num_str.end(), '0' + i, '0' + j);             int new_num = std::stoi(new_num_str);             if (new_num > max_val) {                 max_val = new_num;             }             if (new_num < min_val && (j > 0 || i > 0)) {                 min_val = new_num;             }         }     }     return max_val - min_val;     } };

class Solution(object): def minMaxDifference(self, num): # convert num to a string num_str = str(num) # initialize max and min values to the original number max_val = num min_val = num # try remapping each digit to every possible digit for i in range(len(num_str)): for j in range(10): # skip remapping the digit to itself if j == int(num_str[i]): continue # create the new number after remapping the digit new_num_str = num_str[:i] + str(j) + num_str[i+1:] new_num = int(new_num_str) # update the max and min values if necessary if new_num > max_val: max_val = new_num if new_num < min_val: min_val = new_num # return the difference between the max and min values return max_val - min_val

Will you give today's leetcode biweekly contest?
Anonymous voting

#include <bits/stdc++.h> using namespace std; #define int long long int signed main() {     int t;     cin>>t;     while(t--){     int n;         cin>>n;         int a[n];         int b[n];         for(int i=0;i<n;i++){             cin>>a[i];         }         for(int i=0;i<n;i++){             cin>>b[i];         }         int c[n];         for(int i=0;i<n;i++){             c[i]=0;         }         for(int i=0;i<n;i++){             int from=i;             int till=n-1;             while(true){                 if(a[i]>b[from]){c[from]=c[from]+b[from];a[i]=a[i]-b[from];}                 else{c[from]=c[from]+a[i];a[i]=0;}                 from++;                 if(a[i]==0){break;}                 if(from>till){break;}             }         }         for(int i=0;i<n;i++){             cout<<c[i]<<" ";         }         cout<<endl;     }     return 0; }

If you need d code then dm me

Subscribe for more

#include <iostream> #include <bits/stdc++.h> using namespace std; #define ll long long const int N=2e5+5; void run_test() { int n,i,k,l,r,end=0,start=0; cin>>n>>k; for(i=0;i<n;i++) { cin>>l>>r; if(l==k) { start++; } if(r==k) { end++; } } if(start>0 and end>0) { cout<<"YES"<<endl; return; } cout<<"NO"<<endl; } int main() { int t; cin>>t; while(t--) run_test(); return 0; }

int main() {     int t;     cin >> t;     while(t--)     {         int n,m,cnt=0;         cin >> n >> m;         string a,b;         cin >> a >> b;         reverse(b.begin(),b.end());         string s= a+b ;         // cout << s << "\n";         for(int i=0;i<(n+m-1);i++)         {             if(s[i]==s[i+1])             {                 cnt++;             }         }         if(cnt>1)         {             cout << "NO\n";         }         else         {             cout << "YES\n";         }     } }

Contact me before your coding round and book your slot 100% solutions guaranteed 🔥🔥🔥🔥🔥 ‼️‼️‼️‼️‼️‼️‼️‼️‼️‼️ Solution for all companies will be available 🎁🎁🎁🎁🎁🎁🎁🎁🎁🎁🎁 Get a special discount Dm @Cpsoln ‼️‼️‼️‼️‼️‼️‼️‼️‼️‼️‼️‼️ Don't trust on other telegram channels they will take money and block you

At 2250 subscribers I will post C

B code 🥳🥳🥳🥳

int x, y; cin >> x >> y; cout << ((x - y) + (x - 1 - y) + 1) << endl; for (long i = y + 1; i <= x; i++)cout << (i) << " "; for (long i = x - 1; i >= y; i--)cout << i << " "; cout << endl;

At 2250 subscribers I will post B and C