Пікірлер
@Maneendhar
@Maneendhar Сағат бұрын
Thanks bro it’s really helpful ❤
@nicspyy
@nicspyy 3 сағат бұрын
A solution: void solve() { string s; cin>>s; int n = s.size(); for(int i=0; i<n-2; i++){ cout<<s[i]; } cout<<'i'<<' '; } --------------------------------------------------------------------------------- --------------------------------------------------------------------------------- B solution: void solve() { stack<char>st; string s; cin>>s; int n = s.size(); int cnt = -1; int flag = 0; for(int i=1; i<n; i++){ if(s[i] == s[i-1]){ cnt = i; } } if(cnt == -1) cout<<n; else cout<<1; cout<<' '; // cout<<(n-cn)<<' '; } --------------------------------------------------------------------------------- --------------------------------------------------------------------------------- C solution: void solve() { int n,m; cin>>n>>m; vi a(n); forn(i,0,n) cin>>a[i]; set<int> st; forn(i,0,m){ int x; cin>>x; st.insert(x); } vi b(all(st)); if(b[b.size()-1]-a[n-1] > a[n-1]){ a[n-1] = b[b.size()-1]-a[n-1]; } for(int i=n-2; i>=0; i--){ if(a[i] > a[i+1]){ int val = a[i] + a[i+1]; int ind = lower_bound(all(b), val) - b.begin(); if(ind == b.size()) ind--; if(ind == 0){ if(b[ind] > val){ cout<<"no "; return; }else{ a[i] = b[ind]-a[i]; } }else{ if(b[ind] > val){ a[i] = b[ind-1]-a[i]; }else{ a[i] = b[ind]-a[i]; } } }else if(a[i] < a[i+1]){ int val = a[i] + a[i+1]; int ind = lower_bound(all(b), val) - b.begin(); if(ind == b.size()) ind--; if(ind == 0){ if(b[ind] > val){ // cout<<"no "; // return; }else{ if(a[i] < b[ind]-a[i]){ a[i] = b[ind]-a[i]; } } }else{ if(b[ind] > val){ if(a[i] < b[ind-1]-a[i]){ a[i] = b[ind-1]-a[i]; } }else{ if(a[i] < b[ind]-a[i]){ a[i] = b[ind]-a[i]; } } } } // for(auto j: a) cout<<j<<' '; // cout<<' '; } cout<<"yes "; } --------------------------------------------------------------------------------- --------------------------------------------------------------------------------- D solution: void solve() { int n,m; cin>>n>>m; vector<vi> a(n, vi(m, 0)); for(int i=0; i<n; i++){ for(int j=0; j<m; j++){ cin>>a[i][j]; } } vpp arr; for(int i=0; i<n; i++){ int cnt = 0; int sum = 0; for(int j=0; j<m; j++){ cnt += a[i][j]; // sum += cnt; } arr.pb({cnt, i}); } sort(rall(arr)); vi final; for(auto i: arr){ // cout<<i.ff<<' '<<i.ss<<' '; for(auto k: a[i.ss]){ final.pb(k); } } // for(auto i: final){ // cout<<i<<' '; // }cout<<' '; int ans = 0; int cnt = 0; for(int i=0; i<final.size(); i++){ cnt += final[i]; ans += cnt; } cout<<ans<<' '; } --------------------------------------------------------------------------------- --------------------------------------------------------------------------------- E solution: void solve() { int n,m,k; cin>>n>>m>>k; if(abs(n-m) > k){ cout<<-1<<' '; return; } if(max(n,m) < k){ cout<<"-1 "; return; } int len = n+m; if (n > m){ forn(i,0,k) cout<<0; n -= k; int cnt = 0; forn(i,k,len){ if(cnt == 0 || n == 0) { cout<<1; m--; } else{ cout<<0; n--; } cnt = 1-cnt; } } else { forn(i,0,k) cout<<1; m -= k; int cnt = 0; forn(i,k,len){ if(cnt == 0 || m == 0) { cout<<0; n--; } else{ cout<<1; m--; } cnt = 1-cnt; } } cout<<' '; }
@educationright6025
@educationright6025 9 күн бұрын
Q galat information de rha bhai
@educationright6025
@educationright6025 9 күн бұрын
“C:\MinGW\lib\gcc\mingw32\6.3.0\include\c++\mingw32\bits isko paste karne ke bad enter karte hai browser open hota hai
@educationright6025
@educationright6025 9 күн бұрын
“C:\MinGW\lib\gcc\mingw32\6.3.0\include\c++\mingw32\bits ye kaise kia ,samajh nhi aaya ..paste kar rha hu explorer me kuch nhi ho rha
@nicspyy
@nicspyy 8 күн бұрын
@@educationright6025 check where cpp is installed
@hamedhasanself-employed3362
@hamedhasanself-employed3362 10 күн бұрын
why did you choose 1 to 100 , not clear
@assassinsgaming8591
@assassinsgaming8591 14 күн бұрын
thank you brother
@bostingbolster3385
@bostingbolster3385 14 күн бұрын
Helpful
@minium_realgar_orpiment_6789
@minium_realgar_orpiment_6789 16 күн бұрын
Beautiful, thanks brother. Much love. ❤❤
@zeeezz2986
@zeeezz2986 13 күн бұрын
can sublime text on windows 7 ?
@saketsoni2587
@saketsoni2587 19 күн бұрын
Thanks
@VipinJain-l2n
@VipinJain-l2n 20 күн бұрын
Nice approach. Better than tutorial.
@letschange2985
@letschange2985 20 күн бұрын
Bhai sahi explanation thi Ek suggestion tha, agar script likhkar video shoot karoge tho bolte time kam mistake hoki Baki, looking forward to more such short and crisp explanatory videos
@ThePROestRedn99
@ThePROestRedn99 21 күн бұрын
Thanks
@nicspyy
@nicspyy 21 күн бұрын
B solution: void solve() { int n,m; cin>>n>>m; vector<vi> a(n, vi(m,0)); map<int,set<int>> mp; for(int i=0; i<n; i++){ for(int j=0; j<m; j++){ int x; cin>>x; mp[x].insert(i); } } vector<int> ans; int lastNum = -1; for(int i=0; i<n*m; i++){ int loc = *mp[i].begin(); mp[i].erase(loc); if(ans.size() and ans.back() == loc){ cout<<-1<<' '; return; } ans.pb(loc); if(ans.size() == n){ lastNum = i; break; } } int ind = 0; for(int i=lastNum+1; i<n*m; i++){ int loc = *mp[i].begin(); mp[i].erase(loc); if(loc != ans[ind]){ cout<<-1<<' '; return; } ind = (ind+1)%n; } for(auto i: ans){ cout<<(i+1)<<' '; }cout<<' '; } C solution: void solve() { int n,k; cin>>n>>k; vi a(n); forn(i,0,n) cin>>a[i]; map<int,int> mp; for(auto i: a) mp[i]++; int cnt = 0; for(auto &i: mp){ int sec = k - i.ff; if(mp.count(sec) == 0) continue; if(i.ff == sec){ cnt += mp[i.ff]/2; }else{ int x = min(mp[i.ff], mp[sec]); // cout<<x<<' '; cnt += x; mp[i.ff] -= x; mp[sec] -= x; } } cout<<cnt<<' '; } D solution: void solve() { int n; cin>>n; vi a(n); forn(i,0,n) cin>>a[i]; for(int i=0; i<n-1; i++){ int ind1 = a[i]; int ind2 = a[i+1]; if(ind1 <= ind2){ a[i+1] -= a[i]; a[i] = 0; }else{ cout<<"no"<<' '; return; } } cout<<"yes "; } E solution: class DisjointSet { public: vector<int> rank, parent; DisjointSet(int n) { rank.resize(n + 1, 0); parent.resize(n + 1); for (int i = 0; i <= n; i++) { parent[i] = i; } } int findPar(int node) { if (node == parent[node]) return node; return parent[node] = findPar(parent[node]); } void unionByRank(int u, int v) { int ulp_u = findPar(u); int ulp_v = findPar(v); if (ulp_u == ulp_v) return; if (rank[ulp_u] < rank[ulp_v]) { parent[ulp_u] = ulp_v; } else if (rank[ulp_v] < rank[ulp_u]) { parent[ulp_v] = ulp_u; } else { parent[ulp_v] = ulp_u; rank[ulp_u]++; } } }; void solve() { int n,m1,m2; cin>>n>>m1>>m2; int x = max(m1, m2); DisjointSet *d1 = new DisjointSet(n+1); DisjointSet *d2 = new DisjointSet(n+1); vpp a1, a2; forn(i,0,m1){ int a,b; cin>>a>>b; a1.pb({a,b}); } forn(i,0,m2){ int a,b; cin>>a>>b; a2.pb({a,b}); d2->unionByRank(a, b); } int rem = 0; int add = 0; for(auto &i: a1){ if(d2->findPar(i.ff) == d2->findPar(i.ss)){ d1->unionByRank(i.ff, i.ss); continue; }else{ i.ff = 0; i.ss = 0; rem++; } } for(auto &i: a2){ if(d1->findPar(i.ff) == d1->findPar(i.ss)) continue; d1->unionByRank(i.ff, i.ss); add++; } cout<<add+rem<<' '; }
@Sanakaur9
@Sanakaur9 22 күн бұрын
Thanks bhai
@SailendraChettri-e1f
@SailendraChettri-e1f 25 күн бұрын
Thanks man :)
@yashshukla1637
@yashshukla1637 27 күн бұрын
Thank you so much!
@nicspyy
@nicspyy 28 күн бұрын
B solution: void solve() { int n; cin>>n; vi a(n); forn(i,0,n) cin>>a[i]; vi b(n); forn(i,0,n) cin>>b[i]; int maxInc = 0; int ind = 0; forn(i,0,n){ if(a[i] < b[i] && abs(a[i]-b[i]) >= maxInc){ ind = i; maxInc = abs(a[i]-b[i]); } } forn(i,0,n){ if(i!=ind && a[i]-maxInc < b[i]){ cout<<"no "; return; } } cout<<"yes "; } C solution: void solve() { int n,m; cin >> n >>m; string s; cin >> s; vector<vector<int>> v(n,vector<int>(m)); for(int i = 0;i<n;i++) { for(int j =0;j<m;j++) { int num; cin >> num; v[i][j] = num; } } int curi = 0; int curj = 0; for(int i = 0;i<s.size();i++) { int sum = 0; if(s[i]=='D') { for(int j = 0;j<m;j++) { sum+=v[curi][j]; } v[curi][curj] = -sum; curi++; } else{ for(int k = 0;k<n;k++) { sum+=v[k][curj]; } v[curi][curj] = -sum; curj++; } } int sum2 = 0; for(int j = 0;j<m;j++) { sum2+=v[n-1][j]; } v[n-1][m-1] = -sum2; for(int i = 0;i<n;i++) { for(int j = 0;j<m;j++) { cout << v[i][j] << ' '; } cout << ' '; } cout << ' '; }
@surajkasaudhan1897
@surajkasaudhan1897 29 күн бұрын
Nice explanation
@shashhid___98gg
@shashhid___98gg Ай бұрын
Most underrated channel on KZbin Seriously!!! Salute to you bro have been following you since from long time
@nicspyy
@nicspyy 29 күн бұрын
Thanks, bro
@rahulshendre7089
@rahulshendre7089 Ай бұрын
thanks man
@SarangNayakBala
@SarangNayakBala Ай бұрын
👌🏻
@rameshkrishnan6987
@rameshkrishnan6987 Ай бұрын
I have a question guys , I am really confused whether to learn dsa using java or python , python feels simple and easy but java is verbose. Which will be better or maybe useful
@bavnitsingh23
@bavnitsingh23 Ай бұрын
Language hardly matters just your logic matters the most Cpp, python, java kisi me bhi start kar sakte ho
@Sonu.Singh.28
@Sonu.Singh.28 13 күн бұрын
I would say go with Python because in the Interview you would want to spend minimum time in actually typing the code and utilizing most of the time for solving the problem.
@dhvia
@dhvia Ай бұрын
its actually cool
@gadayash
@gadayash Ай бұрын
Worked for me if the repo is PUBLIC not private
@gadayash
@gadayash Ай бұрын
Really cool man Keep making such content
@AdityaKumar-js6ye
@AdityaKumar-js6ye Ай бұрын
great video anything similar for codeforces, codechef or gfg??
@nicspyy
@nicspyy Ай бұрын
earlier I used to have for GFG too, but its not working anymore now
@AdityaKumar-js6ye
@AdityaKumar-js6ye Ай бұрын
@@nicspyy ok thanks, no problem
@rishabhkaushick
@rishabhkaushick Ай бұрын
I've been syncing my LeetCode progress manually to GitHub, but interesting that there is an extension to do this!
@ttowe
@ttowe Ай бұрын
cool
@anshu_DS
@anshu_DS Ай бұрын
Does it also copies link of the question which one solved from leetcode to github?
@gadayash
@gadayash Ай бұрын
No, only newly solved ones
@nicspyy
@nicspyy Ай бұрын
you can paste the link in code itself, for a work around 🤔🤔
@randomize380
@randomize380 Ай бұрын
Having windows error 2 file specified not found
@nicspyy
@nicspyy Ай бұрын
try refering this link www.geeksforgeeks.org/setting-up-sublime-text-for-cpp-competitive-programming-environment/
@webLoverBirds
@webLoverBirds Ай бұрын
awesome bro ..... maja a geya ... really ..🥰💓
@PreetamRaj-eu7kj
@PreetamRaj-eu7kj Ай бұрын
hello bhai , tum shi mein bhot madad kar rhe ho, but pls kya tum javascript by jonas schmedtmann ya phir angela yu ka latwst course de sakte ho web development ka
@nicspyy
@nicspyy Ай бұрын
@@PreetamRaj-eu7kj noted, will make the video if I got them
@PreetamRaj-eu7kj
@PreetamRaj-eu7kj Ай бұрын
@@nicspyy tnx 🙏 , apka aabhar🙏🙏
@sashibhushanarajput1194
@sashibhushanarajput1194 Ай бұрын
I am the 1000th subscriber. Hope to see more of your content. Keep going buddy !!!
@nicspyy
@nicspyy Ай бұрын
@@sashibhushanarajput1194 🎊🎊🎊🎊🎉🎉🎉🎉 thanks buddy
@AkshatGupta-ug6ex
@AkshatGupta-ug6ex Ай бұрын
Bc sahi se bata de c batana ho to
@barman1734
@barman1734 Ай бұрын
How did the formula for C came ??? Dont call a "reading out" of solution an editorial.
@nicspyy
@nicspyy Ай бұрын
I am not denying that proof is not there, but during contest I saw this pattern, so didn't aimed for finding proof also
@kushwanthaddepalli5236
@kushwanthaddepalli5236 Ай бұрын
Nice explanation. Thanks bhai!
@nicspyy
@nicspyy Ай бұрын
thanks
@ananyerawat-m6f
@ananyerawat-m6f Ай бұрын
6:46 it should be 0110.
@nicspyy
@nicspyy Ай бұрын
rigth
@mohdkashif9830
@mohdkashif9830 Ай бұрын
thanks a lot bro well explained!!
@nicspyy
@nicspyy Ай бұрын
@@mohdkashif9830 thanks
@suryxnz
@suryxnz Ай бұрын
Great explanation brother
@nicspyy
@nicspyy Ай бұрын
@@suryxnz thanks
@theslimeoxidizer3308
@theslimeoxidizer3308 Ай бұрын
brother youre doing really great . how can we perform good in contests
@nicspyy
@nicspyy Ай бұрын
@@theslimeoxidizer3308 it's just "not giving up on a question to early" maybe 🤔
@_hacker-rz2pk
@_hacker-rz2pk Ай бұрын
nice work brother
@nicspyy
@nicspyy Ай бұрын
@@_hacker-rz2pk thanks
@nicspyy
@nicspyy Ай бұрын
please see this image for c's case with k==2 drive.google.com/file/d/1YTUALw1qMOlqAcJeX4855HkIq0pgIqXU/view?usp=sharing B solution: void solve() { int n; cin>>n; map<int,int> mp; vpp a(n); set<int> st; forn(i,0,n){ cin>>a[i].ff; cin>>a[i].ss; if(a[i].ff == a[i].ss){ st.insert(a[i].ff); mp[a[i].ff]++; } } vi temp (all(st)); vector<int> ans(n); for(int i=0; i<n; i++){ if(a[i].ff == a[i].ss){ if(mp[a[i].ff] > 1){ ans[i] = 0; }else{ ans[i] = 1; } }else{ int ind1 = lower_bound(all(temp), a[i].ff) - temp.begin(); int ind2 = lower_bound(all(temp), a[i].ss) - temp.begin(); if(ind1 != temp.size() and ind2 != temp.size() and temp[ind1] == a[i].ff and temp[ind2] == a[i].ss and ind2-ind1+1 == a[i].ss - a[i].ff + 1 ){ ans[i] = 0; }else{ ans[i] = 1; } } } for(auto i: ans){ cout<<i; } cout<<' '; } C solution: pair<int,int> f(int l, int r, int k) { if (r-l+1 < k) { return {0, 0}; } int mid = l+(r-l)/2; if ((r-l+1)%2){ pair<int,int> val = f(l, mid - 1, k); int sum = mid + 2 * val.ff + (mid * val.ss); int segNum = 2 * val.ss + 1; return {sum, segNum}; }else{ pair<int, int> val = f(l, mid, k); int sum = 2 * val.ff + mid * val.ss; int segNum = 2 * val.ss; return {sum, segNum}; } } void solve() { int n,k; cin>>n>>k; cout<<f(1, n, k).ff<<' '; } D solution: const int maxn = 1e6; int a[maxn] , b[maxn]; int powmod(int x , int y){ if(y == 0) return 1; int m = y / 2; int res = powmod(x , m); res = (res * res) % mod; if(y%2 == 1) res = (res * x) % mod; return res; } void solve() { int n , q; cin >> n >> q; vector<int> v1 , v2; for(int i = 0 ; i < n ; i ++ ){ cin >> a[i]; v1.pb(a[i]); } for(int i = 0 ; i < n ; i ++ ){ cin >> b[i]; v2.pb(b[i]); } sort(v1.begin() , v1.end()); sort(v2.begin() , v2.end()); map<int,int> lastA , lastB , cntA , cntB; int res = 1; for(int i = 0 ; i < n ; i ++ ){ lastA[v1[i]] = i; lastB[v2[i]] = i; cntA[v1[i]] ++ ; cntB[v2[i]] ++ ; res = res * min(v1[i] , v2[i]); res = res % mod; } vector<int> ans; ans.pb(res); while(q--){ int type, ind; cin>>type>>ind; ind-- ; if(type == 1){ int x = a[ind]; int i = lastA[x]; cntA[x]--; if(cntA[x] == 0) lastA[x] = -1; else lastA[x]--; res = (res * powmod(min(v1[i] , v2[i]) , mod-2)) % mod; v1[i]++; a[ind]++; cntA[v1[i]]++; if(cntA[v1[i]] == 1) lastA[a[ind]] = i; res = res*min(v1[i] , v2[i]); res %= mod; } else{ int x = b[ind]; int i = lastB[x]; cntB[x] -- ; if(cntB[x] == 0) lastB[x] = 0; else lastB[x] -- ; res = res * powmod(min(v1[i] , v2[i]) , mod - 2) % mod; v2[i]++; b[ind]++; cntB[v2[i]]++; if(cntB[v2[i]] == 1) lastB[b[ind]] = i; res = res *min(v1[i] , v2[i]); res %= mod; } ans.pb(res); } for(auto x : ans) cout << x << " "; cout<<' '; }
@Travel-s5e
@Travel-s5e Ай бұрын
Explanation why for C limit is 2*n ? (only see if you understood all other part and point of the question ) See, its actually simple when you realize. There we are given A with length n right ? What is the best score we can get out of A by performing PREFIX ADD operations ? lets say X , now what is the maximum value of X ? obviously "n" right ? because there are "n" elements in "a" , so it makes sense. to score "n" without optimizing , if we blindly go NO BRAINER approach like below seq ADD , SCORE , ADD, SCORE, ADD ..... like this, it will take like 2*n operations (n add n score) right to reach "n" score ? that's why we can't afford more than 2*n operations on figuring out the most optimal solution. if 2*n operations already done, that best we could have achieved was n , and that same can be achieved by the no brainer approach I mentioned above so we won't calculate further.
@sibiaadharshdamodaransampa479
@sibiaadharshdamodaransampa479 Ай бұрын
Situation Task ,action,result (STAR) -witht he resources avaiable in online, posting thse videos help us prepare rigorously and ace the interviews excellently..
@sibiaadharshdamodaransampa479
@sibiaadharshdamodaransampa479 Ай бұрын
Brilliant techie!!! pivoting to diffent skillsets - java spring boot data science, android deelopent- woman security app, placement app, is your next career- cryptography engineer or algorithm designer
@samakshgoswami
@samakshgoswami Ай бұрын
thanks bhai it works
@Vaddipalli
@Vaddipalli Ай бұрын
From which IIT, she was passed out
@nicspyy
@nicspyy Ай бұрын
LPU,
@Vaddipalli
@Vaddipalli Ай бұрын
@@nicspyy Oh great 👍
@cqwshi
@cqwshi Ай бұрын
bhai teri cf profiile?
@balajee4546
@balajee4546 Ай бұрын
Can you show your profile link