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
If anyone want help in codekaze coding round on 17 then Dm @Cpsoln.
Codeforces id on sale
If you want then only Dm @Cpsoln
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 ✅✅✅✅
class Solution:
def goodSubsetofBinaryMatrix(self, grid: List[List[int]]) -> List[int]:
for i, e in enumerate(grid):
if sum(e) == 0:
return [i]
for i in range(len(grid)):
for j in range(i+1, len(grid)):
if sum([a and b for a, b in zip(grid[i], grid[j])]) == 0:
return [i, j]
return []
Solution to Leetcode D
Stay away from other channels they all are scammers....
class Solution {
public:
vector goodSubsetofBinaryMatrix(vector>& grid) {
vector result;
for (int i = 0; i < grid.size(); i++) {
int rowSum = 0;
for (int j = 0; j < grid[i].size(); j++) {
rowSum += grid[i][j];
}
if (rowSum == 0) {
result.push_back(i);
return result;
}
}
for (int i = 0; i < grid.size(); i++) {
for (int j = i + 1; j < grid.size(); j++) {
int colSum = 0;
for (int k = 0; k < grid[i].size(); k++) {
colSum += (grid[i][k] && grid[j][k]);
}
if (colSum == 0) {
result.push_back(i);
result.push_back(j);
return result;
}
}
}
return result;
}
};
class Solution {
public:
int mod=(1e9 + 7);
int sumDistance(vector& nums, string s, int d) {
for (int i = 0; i < s.size(); i++) {
if (s[i] == 'L') {
nums[i] -= d;
} else if (s[i] == 'R') {
nums[i] += d;
}
}
sort(nums.begin(), nums.end());
long long sum = 0;
long long ans = 0;
for (int i = 0; i < nums.size(); i++) {
ans += 1LL*nums[i] * i - sum;
ans%=mod;
sum += nums[i];
sum%=mod;
}
return ans % (int)(1e9 + 7);
}
};
class Solution {
public:
int longestSemiRepetitiveSubstring(string s) {
int ans=0;
for(int i=0;i=2) flag = 1;
}
}
if(!flag) ans=max(ans, (int)t.size());
}
}
return ans;
}
};
class Solution {
public:
int mod=(1e9 + 7);
int sumDistance(vector& nums, string s, int d) {
for (int i = 0; i < s.size(); i++) {
if (s[i] == 'L') {
nums[i] -= d;
} else if (s[i] == 'R') {
nums[i] += d;
}
}
sort(nums.begin(), nums.end());
long long sum = 0;
long long ans = 0;
for (int i = 0; i < nums.size(); i++) {
ans += 1LL*nums[i] * i - sum;
ans%=mod;
sum += nums[i];
sum%=mod;
}
return ans % (int)(1e9 + 7);
}
};
Codeforces Soultion:
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define int long long
void sol(){
string a,b;
cin>>a>>b;
int t,q;
cin>>t>>q;
vector<char> aa,bb;
for(auto val:a){
aa.push_back(val);
}
for(auto val:b){
bb.push_back(val);
}
int n = a.size();
int count=0;
for(int i=0;i<n;i++){
if(a[i]!=b[i]) count++;
}
// cout<<count<<endl;
map<int,int> m;
int timer=1;
while(q--){
int qqq;
cin>>qqq;
if(m[timer]!=0){
count++;
}
if(qqq==1){
int pos;
cin>>pos;
pos--;
if(aa[pos]!=bb[pos]){
m[timer+t]++;
count--;
}
}
else if(qqq==2){
int qq,ww,pos1,pos2;
cin>>qq>>pos1>>ww>>pos2;
pos1--;
pos2--;
if(aa[pos1]==bb[pos1]) count++;
if(aa[pos2]==bb[pos2]) count++;
char s1;
if(qq==1){
// cout<<"here"<<endl;
s1 = aa[pos1];
}
else{
s1 = bb[pos1];
}
char s2;
if(ww==1){
s2 = aa[pos2];
}
else{
s2 = bb[pos2];
}
if(qq==1){
aa[pos1] = s2;
}
else{
bb[pos1] = s2;
}
if(ww==1){
aa[pos2]=s1;
}
else{
bb[pos2]=s1;
}
if(aa[pos1]==bb[pos1]) count--;
if(aa[pos2]==bb[pos2]) count--;
// cout<<s1<<" "<<s2<<" "<<count<<endl;
}
else{
if(count==0){
cout<<"yes"<<endl;
}
else{
cout<<"no"<<endl;
}
}
// cout<<count<<endl;
timer++;
}
return;
}
signed main() {
int test=1;
cin>>test;
while(test--){
sol();
}
return 0;
}
#include <string>
#include <unordered_set>
class Solution {
public:
bool isFascinating(int num) {
std::string concatenated = std::to_string(num) + std::to_string(2 * num) + std::to_string(3 * num);
if (concatenated.length() != 9) {
return false;
}
std::unordered_set<char> uniqueDigits(concatenated.begin(), concatenated.end());
return uniqueDigits.size() == 9 && uniqueDigits.find('0') == uniqueDigits.end();
}
};
We suggest you to apply for this event as it held only once in the year.
All the batches must apply and specially 2024 / 2025 / 2026 batch must apply in this as it will help you practice for your upcoming hiring challenges.
Must Apply - CodeKaze ✅
Register Link:
https://bit.ly/Mega_Hiring_June
Registration Deadline: 10 June (Tomorrow)
