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 more4 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 num1,num2;
cin>>num1>>num2;
cout<<num2*2+num1*1<<endl;
}
return 0;
}
Hurry UP! 🏃♂ Only 1 Day Left
Register Fast 🚨
Juspay Hiring
Batch Eligible: 2022, 2023, 2024, 2025 and 2026
Internship Stipend: Rs.40K/month
PPO CTC: INR 21-30 LPA
Registration Link: Hurry UP! 🏃♂ Only 1 Day Left
Register Fast 🚨
Juspay Hiring
Batch Eligible: 2022, 2023, 2024, 2025 and 2026
Internship Stipend: Rs.40K/month
PPO CTC: INR 21-30 LPA
Registration Link: https://bit.ly/Juspay_NammaYatri
Share with your Friends too
Share with your Friends too
Repost from Codeforces|Leetcode|Codechef free solutions
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 ✅✅✅✅
Largest Y
C++
Codechef Starters 86
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t = 1;
cin >> t;
for (int i = 1; i <= t; i++)
{
int n, x;
cin >> n >> x;
vector<int> a(n);
for (int i = 0; i < n; i++)
cin >> a[i];
int ans = 0;
for (int i = 0; i < 30; i++)
{
int m = 0;
for (int j = 0; j < n; j++)
m |= 1 << ((a[j] >> i) & 1);
if (m != 3)
continue;
int t = x;
if (t & (1 << i))
{
t ^= 1 << i;
for (int j = i - 1; j >= 0; j--)
t |= 1 << j;
}
ans = max(ans, t);
}
cout << ans << endl;
}
}
Largest Y
C++
Codechef Starters 86
Minimum Operation
C++
Codechef Starters 86
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int NAX = 1e6 + 1;
vector<int> pr, lpf(NAX);
vector<bool> is_prime(NAX, true);
is_prime[0] = is_prime[1] = false;
for (int i = 2; i < NAX; i++)
{
if (is_prime[i])
{
pr.push_back(i);
lpf[i] = i;
for (int j = i * i; j < NAX; j += i)
{
is_prime[j] = false;
lpf[j] = i;
}
}
}
int t = 1;
cin >> t;
for (int ii = 1; ii <= t; ii++)
{
int n, x, g = 0;
cin >> n >> x;
vector<int> a(n);
for (int i = 0; i < n; i++)
cin >> a[i], g = __gcd(g, a[i]);
unordered_set<int> s(a.begin(), a.end());
if (s.size() == 1)
{
cout << 0 << endl;
continue;
}
unordered_set<int> p;
for (int i = 0; i < n; i++)
{
int t = a[i];
while (t > 1)
{
int f = lpf[t];
p.insert(f);
while (t % f == 0)
t /= f;
}
}
set<int> gp;
while (g > 1)
{
int f = lpf[g];
gp.insert(f);
while (g % f == 0)
g /= f;
}
if (!gp.empty() && *gp.begin() <= x)
{
cout << 1 << endl;
cout << *gp.begin() << endl;
}
else
{
bool ok = false;
int pp = upper_bound(pr.begin(), pr.end(), x) - pr.begin();
for (int i = pp - 1; i >= 0; i--)
{
if (p.find(pr[i]) == p.end())
{
cout << 1 << endl;
cout << pr[i] << endl;
ok = true;
break;
}
}
if (ok)
continue;
cout << "2\n2 3" << endl;
}
}
}
Minimum Operation
C++
Codechef Starters 86
Dm @Cpsoln for DE shaw coding round
Limited slots available
Repost from Codeforces|Leetcode|Codechef free solutions
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 ✅✅✅✅
At 3150+ subscribers I will upload D solution for free
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
auto get_mex = [&](vector<int> &a)
{
int n = a.size();
vector<int> b(n);
for (auto &i : a)
{
if (i < n)
b[i]++;
}
int mex = 0;
while (mex < n && b[mex])
mex++;
return mex;
};
int t = 1;
cin >> t;
while (t--)
{
int n;
cin >> n;
vector<int> a(n), b(n);
for (auto &i : a)
cin >> i;
int mex = get_mex(a);
if (mex == n)
{
cout << "No" << endl;
continue;
}
vector<int> to_rem;
if (find(a.begin(), a.end(), mex + 1) != a.end())
{
for (int i = 0; i < n; i++)
{
if (a[i] == mex + 1)
to_rem.push_back(i);
}
for (int i = to_rem.front(); i <= to_rem.back(); i++)
a[i] = mex;
if (get_mex(a) == mex + 1)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
else
cout << "Yes" << endl;
}
}
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a.begin(), a.end());
int mex = 0;
for (int i = 0; i < n; i++) {
if (a[i] == mex) {
mex++;
}
}
bool found = false;
for (int i = 0; i < n; i++) {
if (a[i] == mex) {
found = true;
break;
}
}
if (found || (mex == n)) {
cout << "Yes\n";
} else {
cout << "No\n";
}
}
return 0;
}
At 3.1k subscribers I will post C and D
So share this channel to your friends
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(n) for(long long i=0;i<n;i++)
signed main(){
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output1.txt","w",stdout);
#endif
int t;
cin>>t;
while(t--){
string s;
cin>>s;
ll n=s.size();
ll cnt=0;
for(int i=0;i<s.size();i++){
if(s[i]=='1')cnt++;
}
if(cnt==s.size())cout<<n*n<<"\n";
else {
ll cmt=0,p=0,i=0;cnt=0;
while(true){
if(s[i%n]=='1')cnt++;
else {
cmt=max(cmt,cnt);
cnt=0;
}cmt=max(cmt,cnt);
i++;p++;
if(p>=n&&s[i%n]=='0')break;
}cmt=max(cmt,cnt);
cout<<((cmt+1)*(cmt+1))/4<<"\n";
}
}
return 0;
}
#include<bits/stdc++.h>
using namespace std;
void solve(){
string s;
cin>>s;
string t;
for(auto &it:s){
if(it=='_'){
if(t.empty() || t.back()=='_')
t.push_back('^');
t.push_back('_');
}
else
t.push_back(it);
}
if(t.back()=='_')
t.push_back('^');
if(t.size()==1)
t+='^';
cout<<t.size()-s.size()<<"\n";
}
int main(){
int t;
cin>>t;
while(t--){
solve();
}
return 0;
}
