- 86
- 11 216
LearnCode
India
เข้าร่วมเมื่อ 7 ต.ค. 2012
Amphibian Escape | Codechef Starters 141 | Simple Easy Peasy Explaination
Amphibian Escape | Codechef Starters 141 | Simple Easy Peasy Explaination
#codechefsolutiontoday
#CodeChef Starters 141
#dsa
#codechefsolution 141
#c++
#coding
#programming
#competitive programming
#software developer
#software engineer
#interview preparation
#interview experience
#dsa
#141
#codechefsolutiontoday
#CodeChef Starters 141
#dsa
#codechefsolution 141
#c++
#coding
#programming
#competitive programming
#software developer
#software engineer
#interview preparation
#interview experience
#dsa
#141
มุมมอง: 169
วีดีโอ
Redundant Array | Codechef Starters 141 | Simple Easy Peasy Explaination
มุมมอง 27028 วันที่ผ่านมา
Redundant Array | Codechef Starters 141 | Simple Easy Peasy Explaination 0:00 Nearly Equal 1:29 Reduntant Array #codechefsolutiontoday #CodeChef Starters 141 #dsa #codechefsolution 141 #c #coding #programming #competitive programming #software developer #software engineer #interview preparation #interview experience #dsa #141
Split Permutation | Codechef Starters 140 | Easy Peasy
มุมมอง 53หลายเดือนก่อน
#codechefsolutiontoday #CodeChef Starters 140 #dsa #codechefsolution 140 #c #coding #programming #competitive programming #software developer #software engineer #interview preparation #interview experience #dsa #140
Trick Or Treat | Codechef Starters 140 | Super Easy
มุมมอง 154หลายเดือนก่อน
#codechefsolutiontoday #CodeChef Starters 140 #dsa #codechefsolution 140 #c #coding #programming #competitive programming #software developer #software engineer #interview preparation #interview experience #dsa #140
Make Permutation | Codechef Starters 140 | Easy peasy explaination
มุมมอง 96หลายเดือนก่อน
#codechefsolutiontoday #CodeChef Starters 140 #dsa #codechefsolution 140 #c #coding #programming #competitive programming #software developer #software engineer #interview preparation #interview experience #dsa #140
Biweekly Contest 133 | First 3 problems
มุมมอง 107หลายเดือนก่อน
Find Minimum Operations to Make All Elements Divisible by Three Minimum Operations to Make Binary Array Elements Equal to One I Minimum Operations to Make Binary Array Elements Equal to One II Leetcode 133 biweekly contest FREE SOLUTIONS 0:00 Find Minimum Operations to Make All Elements Divisible by Three 0:34 Minimum Operations to Make Binary Array Elements Equal to One I 2:04 Minimum Operatio...
Sum of N | Codechef Starters 139 | Very Easy Explaination
มุมมอง 844หลายเดือนก่อน
#codechefsolutiontoday #CodeChef Starters 139 #dsa #codechefsolution 139 #c #coding #programming #competitive programming #software developer #software engineer #interview preparation #interview experience #dsa #139
Maximum Distance Permutations | Codechef Starters 139 | Easy Peasy
มุมมอง 853หลายเดือนก่อน
#codechefsolutiontoday #CodeChef Starters 139 #dsa #codechefsolution 139 #c #coding #programming #competitive programming #software developer #software engineer #interview preparation #interview experience #dsa #139
Distinct Substring - Codechef Starters 138
มุมมอง 75หลายเดือนก่อน
#codechefsolutiontoday #CodeChef Starters 138 #dsa #codechefsolution 138 #c #coding #programming #competitive programming #software developer #software engineer #interview preparation #interview experience #dsa #138
Codeforces Round 952 (Div. 4) | Maximum Multiple Sum | Good Prefixes | Manhattan Circle
มุมมอง 134หลายเดือนก่อน
Codeforces Round 952 (Div. 4) | Maximum Multiple Sum | Good Prefixes | Manhattan Circle Codeforces Round 952 (Div. 4) - Live Solving #coding #programming #competitive programming #software developer #software engineer #interview preparation #interview experience #dsa #132
Large Differences | Codechef starters 137 | Simple and easy explaination
มุมมอง 121หลายเดือนก่อน
Large Differences | Codechef starters 137 Hey Guys, If you liked the video , do hit the like button and subscribe my channel . Code is in the comments. #codechefsolutiontoday #CodeChef Starters 132 #dsa #codechefsolution132 #c #coding #programming #competitive programming #software developer #software engineer #interview preparation #interview experience #dsa #132
Even Sum Subarray | Codechef Starters 136 | Simple and Easy
มุมมอง 452 หลายเดือนก่อน
Even Sum Subarray | Codechef Starters 136 | Simple and Easy Hey Guys, If you liked the video , do hit the like button and subscribe my channel . Code is in the comments. #codechefsolutiontoday #CodeChef Starters 132 #dsa #codechefsolution132 #c #coding #programming #competitive programming #software developer #software engineer #interview preparation #interview experience #dsa
My First Geometry Problem | Codechef Starters 136 | Simple and easy
มุมมอง 452 หลายเดือนก่อน
My First Geometry Problem | Codechef Starters 136 | Simple and easy Hey Guys, If you liked the video , do hit the like button and subscribe my channel . Code is in the comments. #codechefsolutiontoday #CodeChef Starters 132 #dsa #codechefsolution132 #c #coding #programming #competitive programming #software developer #software engineer #interview preparation #interview experience #dsa
A. Phone Desktop | Codeforces Round 946 (Div 3) | Explaination on board
มุมมอง 1732 หลายเดือนก่อน
Phone Desktop | Codeforces Round 946 (Div 3) | Explaination on board Hey Guys, If you liked the video , do hit the like button and subscribe my channel . Code is in the comments. #codechefsolutiontoday #CodeChef Starters 132 #dsa #codechefsolution132 #c #coding #programming #competitive programming #software developer #software engineer #interview preparation #interview experience #dsa
3153. Sum of Digit Differences of All Pairs | Weekly Contest 398 | Simple and easy explaination
มุมมอง 1322 หลายเดือนก่อน
3153. Sum of Digit Differences of All Pairs | Weekly Contest 398 | Simple and easy explaination Leetcode Weekly Contest 398 || 100283. Minimum Length of Anagram Concatenation || Q.3 #contest #code Code is in the comments. #codechefsolutiontoday #CodeChef Starters 132 #dsa #codechefsolution132 #c #coding #programming #competitive programming #software developer #software engineer #interview prep...
test case-> 20 6 18. The above formula returns b = 6, when a = 8. So, we can make 6 pairs with dif B. where A = 8, but we can actually make only five pairs (8,5) to (8,1). correct this pls.
great explanation but please show whole code one time during the video
@@banidhanagar6951Tysm and I'll post it in the comments going forwrd.
great explanation!
Thanks
Muze laga x me sirf array ka element le sakte 😢😢
Mera pura logic sahi tha bas ye "long long" ne leli meri 🥲
Thanks a lot for ur effort .
Thanks and hope it helped.
subscribed plz keep uploading
zarur bhai
Great Explanation!
nice explanation
#include <bits/stdc++.h> using namespace std; int main() { // your code goes here int t; cin >> t; while (t--) { int n, m; cin >> n >> m; int choc[n], cand[n]; for (int i = 0; i < n; i++) { cin >> choc[i] >> cand[i]; } int cnt = 0; unordered_map<int,int>mp; for (int i = 0; i < n; i++) { mp[choc[i]%m]++; } for(int i=0;i<n;i++){ int c=cand[i]%m; if(c==0){ cnt+=mp[0]; } else{ cnt+=mp[m-c]; } } cout<<cnt<<endl;} return 0; } this is according to your code but not running for all test cases.Can u tell me why?
bhai yaar break the string wala batao hashing se
I couldn't make it.. Will try to upload soon
Bro, what's your rating in codechef.
1656
@@LearnCodeHS 🙌🙌👍
int,int ka unordered map lene pe wrong as bata raha tha vahi long long lene pe submit ho gya why?
Look at the constraints. N may go upto 10^5. Ek case aisa bhi ho skta jisme array A ka har element array B k har element k sath pair bna le.. In that case.. Vo int range ko cross kr jayega.. Isliye need long long
Good approach
just a suggestion it will be better if you provide question link in description 😊😊. By the way nice content helped me a lot
Sure bro. Thanks a lot
har week daalna video bro, great !
Uske lie Subscribe zarur krna :P. But thanks bro
You have gained a subscriber.Your explanation is very good Sir
Thanks bro. Thanks for the support!
do we need to create an array in manhattan circle , it only increases time complexity , we can do the que without it also . And i am an beginner in cf so can you suggest why you use signed main etc is there any boilerplate code or something to do this ?
The only array I have is the input array. Didn't get you? yes its a boilerplate code and because I am using macro #define int long long , the main function cannot have return type long long , so used 'signed' because signed and int both are same
@@LearnCodeHS yeah but do we need i/p array , i mean we can do it withkut ip array right
@@ishaansharma6553you can but. Input array se tc pr frk nhi padga and What other operations you perform are taken into consideration TC analysis
@@LearnCodeHS you took i/p array and traversed on it for result , i just computed answer in input itself and didnt store it like other
@@ishaansharma6553 That's even nice bro. I couldn't think of it during contest
nice video, to the point and crisp solutions, thank you
searching for this type of explanation and u give it . Great work , keep doing it
Wo first permutations wala question kese hoga
Talking about Maximum distance permutations? This video is already uploaded on my channel
Can you tell me the time complexity of " Sum of N" Implementation in your code. Bcz I wrote same code almost and I also used sieve of Eratosthenes. But I got TLE. My code time is Klog log K + root(K) + atmost K for loop which won't go completely most of times.
TC is correct but are you pre-computing the prefixSumOfNPrimes?
How should I practice to solve these type of questions during the time control. If you can suggest me.
Keep grinding. Practice is the only key . Solve questions above your rating like 200-300+
Thank You Sir, you have explained this question in very simple way. It really helps to understand easily & quickly.
Glad it helped. Happy learning!
#include<bits/stdc++.h> using namespace std; #define int long long bool prime[1000001]; int prefixSum[1000001]={0}; void SieveOfEratosthenes() { memset(prime, true, sizeof(prime)); int e=1000001; for (int p = 2; p * p <= e; p++) { if (prime[p] == true) { for (int i = p * p; i <= e; i += p) prime[i] = false; } } } void prefixSumOfNPrimeNumbers(){ int s=0; for(int i=2;i<=1000001;i++){ if(prime[i]){ s+=i; } prefixSum[i]=s; } } void solve(){ int n; cin>>n; if(n%2==0){ cout<<n*2<<endl; } else if(prime[n]){ cout<<prefixSum[n]*n<<endl; } else{ int divisor=3; for(int i=3;i*i<=n;i+=1){ if(n%i==0){ divisor=i; break; } } cout<<prefixSum[divisor]*n<<endl; } } signed main() { int t; cin>>t; SieveOfEratosthenes(); prefixSumOfNPrimeNumbers(); while(t--){ solve(); } }
D. Manhattan Circle #include<bits/stdc++.h> using namespace std; //check you variables naming,can be repeating #define int long long int void solve(){ int n,m; cin>>n>>m; vector<vector<char>> v(n,vector<char>(m)); for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ cin>>v[i][j]; } } int io=0; int jo=0; int cnt=0; bool f=true; for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ if(v[i][j]=='#'){ cnt=i; // cout<<"cnt "<<cnt<<endl; io=i; jo=j; f=false; break; } } if(!f)break; } while(true){ if(io+1<n && v[io+1][jo]=='#'){ io++; } else{ break; } } cout<<((io+cnt)/2)+1<<" "<<(jo+1)<<endl; } signed main() { int t; cin>>t; while(t--){ solve(); } }
#include<bits/stdc++.h> using namespace std; void solve(){ int n,k; cin>>n>>k; vector<int> v; for(int i=0;i<n;i++){ int e; cin>>e; v.push_back(e); } int sum=0; for(int i=0;i<n-1;i++){ sum+=abs(v[i]-v[i+1]); } int maxi=sum; // bool f=true; for(int i=0;i<n;i++){ // v[i]=j; int o=sum; if(i==0){ o-=abs(v[i]-v[i+1]); o+=abs(1-v[i+1]); } else if(i==n-1){ o-=abs(v[i-1]-v[i]); o+=abs(v[i-1]-1); } else{ o-=abs(v[i]-v[i-1]); o-=abs(v[i]-v[i+1]); o+=abs(1-v[i-1]); o+=abs(1-v[i+1]); } maxi=max(maxi,o); o=sum; if(i==0){ o-=abs(v[i]-v[i+1]); o+=abs(k-v[i+1]); } else if(i==n-1){ o-=abs(v[i-1]-v[i]); o+=abs(v[i-1]-k); } else{ o-=abs(v[i]-v[i-1]); o-=abs(v[i]-v[i+1]); o+=abs(k-v[i-1]); o+=abs(k-v[i+1]); } maxi=max(maxi,o); } cout<<maxi<<endl; } int main() { int t; cin>>t; while(t--){ solve(); } }
Where is the code link?
0 audio
My bad. Will try to fix it from now onwards
Thanks:)
Good explanation bro.....Keep it up
Good job
Great video! Thank you
Bro very well explained ! keep going... looking forward for more videos
Thanks a ton
Brother explain the code properly
Sure. We'll fix it going forward to
bro optimise your mic volume its too low
Thanks for feedback. Will fix it going forward
kya ye optimised solution hai?
ofc not, its the brute force approach that I came up with during contest , but there is a solution in O(N) TC way better than this using gcd
@@LearnCodeHS but that solution is giving WA on some cases and people are discussing that it passed in contest due to weak tc.
@@dhruvrawatt9 honestly I haven't yet went through the solution (gcd wala) , but walked through some tutorials and they too explaining the same appraoch (which I discussed here) , maybe that gcd wali approach is wrong
#include<bits/stdc++.h> using namespace std; void solve(){ int n,k; cin>>n>>k; vector<string> v; for(int i=0;i<n;i++){ string e; cin>>e; v.push_back(e); } set<string> st; for(string s:v)st.insert(s); string temp=""; for(int i=0;i<k;i++){ temp.push_back('0'); } // k==4 // 0000 // for(int i=k-1;i>=0;i--){ temp[i]='1'; if(st.find(temp)==st.end()){ cout<<"NO"<<endl; return ; } temp[i]='0'; } cout<<"YES"<<endl; } int main() { int t; cin>>t; while(t--){ solve(); } }
provide your codeforces handle please;
Thank You bhai.
class Solution { public: bool check(vector<int> &v1,vector<int> &v2){ for(int i=0;i<v1.size()-1;i++){ if(v1[i]-v2[i]!=v1[i+1]-v2[i+1]){ return false; } } return true; } int minimumAddedInteger(vector<int>& nums1, vector<int>& nums2) { sort(nums1.begin(),nums1.end()); sort(nums2.begin(),nums2.end()); int mini=INT_MAX; for(int i=0;i<nums1.size()-1;i++){ for(int j=i+1;j<nums1.size();j++){ vector<int> v; for(int a=0;a<nums1.size();a++){ if(a!=i && a!=j){ v.push_back(nums1[a]); } } if(check(v,nums2)){ mini=min(mini,nums2[0]-v[0]); } } } return mini; } };
class Solution { public: long long numberOfRightTriangles(vector<vector<int>>& grid) { long long ans=0; vector<int> row(grid.size()); vector<int> col(grid[0].size()); for(int i=0;i<grid.size();i++){ int cnt=0; for(int j=0;j<grid[i].size();j++){ cnt+=grid[i][j]; } row[i]=cnt; } for(int j=0;j<grid[0].size();j++){ int cnt=0; for(int i=0;i<grid.size();i++){ cnt+=grid[i][j]; } col[j]=cnt; } for(int i=0;i<grid.size();i++){ for(int j=0;j<grid[0].size();j++){ if(grid[i][j]==1){ if(row[i]>1 && col[j]>1){ ans+=(row[i]-1)*(col[j]-1); } } } } return ans; } };
esse faltu question nee dekhaa bhai , galti ho gayi codechef pe aake bc
#include<bits/stdc++.h> using namespace std; const int MOD=1000000007; #define int long long void solve(){ int n; cin>>n; vector<int>v(n); for(int i=0;i<n;i++){ cin>>v[i]; } sort(v.begin(),v.end()); int s=0; for(int i=0;i<n;i++){ if(s==0 || v[i]==1 || s==1 ){ s+=(v[i]%MOD); s%=MOD; } else{ s=s*(v[i]%MOD); s%=MOD; } } cout<<s%MOD<<endl; } signed main() { int t; cin>>t; while(t--){ solve(); } }
#include<bits/stdc++.h> using namespace std; #define int long long void solve(){ int n,k; cin>>n>>k; vector<int> v; for(int i=0;i<n;i++){ int e; cin>>e; v.push_back(e); } sort(v.begin(),v.end()); int i=0; int ans=0; while(i<n && k>0){ if(v[i]<=3){ ans+=7-v[i]; k--; } else{ ans+=v[i]; } i++; } while(i<n)ans+=v[i++]; cout<<ans<<endl; } signed main() { int t; cin>>t; while(t--){ solve(); } }
#include<bits/stdc++.h> using namespace std; void solve(){ int n; cin>>n; vector<int> v; for(int i=0;i<n;i++){ int e; cin>>e; v.push_back(e); } if(v[0]!=v[n-1]){ cout<<"NO"<<endl; } else{ int mini=*min_element(v.begin(),v.end()); if(mini<v[0]){ cout<<"NO"<<endl; } else{ cout<<"YES"<<endl; } } } int main() { int t; cin>>t; while(t--){ solve(); } }
#include<bits/stdc++.h> using namespace std; void solve(){ int n; cin>>n; string v; cin>>v; vector<int> ans; for(int i=0;i<n-1;i+=2){ if(v[i]!=v[i+1]){ if(ans.empty()) { ans.push_back(i+1); } else{ if(v[ans.back()-1]=='1'){ if(v[i]=='0'){ ans.push_back(i+1); } else{ ans.push_back(i+2); } } else if(v[ans.back()-1]=='0'){ if(v[i]=='1'){ ans.push_back(i+1); } else{ ans.push_back(i+2); } } } } } cout<<ans.size()<<endl; for(auto it:ans){ cout<<it<<" "; } cout<<endl; } int main() { int t; cin>>t; while(t--){ solve(); } }
#include<bits/stdc++.h> using namespace std; void solve(){ int n; cin>>n; string s; cin>>s; string o=""; for(int i=0;i<n;i++){ if(i%2==0){ o.push_back('0'); } else{ o.push_back('1'); } } string k=""; for(int i=0;i<n;i++){ if(i%2==0){ k.push_back('1'); } else{ k.push_back('0'); } } bool f=true; int cnt1=0; for(int i=0;i<n;i++){ if(f){ if(s[i]!=o[i]){ cnt1++; f=false; } } else{ if(s[i]==o[i]){ cnt1++; f=true; } } } f=true; int cnt2=0; for(int i=0;i<n;i++){ if(f){ if(s[i]!=k[i]){ cnt2++; f=false; } } else{ if(s[i]==k[i]){ cnt2++; f=true; } } } cout<<min(cnt1,cnt2)<<endl; } int main() { int t; cin>>t; while(t--){ solve(); } }
bro phle question smzaya kro phir solution batao
dhyan rakhunga