- 485
- 889 716
Abhinav Awasthi
India
Приєднався 4 бер 2017
🔥 Subscribe to coding75 Pro for Regular 1:1 Mentorship, Live Contest Discussions, and Interview Preparation: coding75.com/pro
✅ Live DSA Classes
✅ Codeforces, Codechef, Leetcode Live Discussion
✅ 1:1 Mock Interviews
✅ 1:1 Mentorship Sessions
✅ 1:1 Resume Review
✅ Live Weekly Project Building Sessions
✅ Live CS Fundamental Classes
In case of any queries regarding coding75, WhatsApp us here: wa.me/message/TPN76XLWVOWDB1
Or join our updates group: chat.whatsapp.com/KAXRJJUx2lA7Ur7FJI4uio
🚀 Join Telegram for Post Contest Discussions, Coding Meets, and Important Updates, Join a Community of over 20,000+ Coders: t.me/cpabhinav
I am Abhinav Awasthi, currently working as a Software Development Engineer Intern at Zeta-Directi. Previously, I worked at LinkedIn and GeeksforGeeks.
I have been ranked in the top 1.0% of competitive programmers in India on CodeChef, I have a 5-star rating, expert status on Codeforces, and an ICPC Regionalist with a rank of 57.
✅ Live DSA Classes
✅ Codeforces, Codechef, Leetcode Live Discussion
✅ 1:1 Mock Interviews
✅ 1:1 Mentorship Sessions
✅ 1:1 Resume Review
✅ Live Weekly Project Building Sessions
✅ Live CS Fundamental Classes
In case of any queries regarding coding75, WhatsApp us here: wa.me/message/TPN76XLWVOWDB1
Or join our updates group: chat.whatsapp.com/KAXRJJUx2lA7Ur7FJI4uio
🚀 Join Telegram for Post Contest Discussions, Coding Meets, and Important Updates, Join a Community of over 20,000+ Coders: t.me/cpabhinav
I am Abhinav Awasthi, currently working as a Software Development Engineer Intern at Zeta-Directi. Previously, I worked at LinkedIn and GeeksforGeeks.
I have been ranked in the top 1.0% of competitive programmers in India on CodeChef, I have a 5-star rating, expert status on Codeforces, and an ICPC Regionalist with a rank of 57.
A-D | Leetcode Weekly Contest 414 Editorials | Maximum Number of Moves to Kill All Pawns | Abhinav
Contest Link: leetcode.com/contest/weekly-contest-414/
Problem A: coding75.com/dsa-cp/leetcode-contests/3280-convert-date-to-binary-weekly-contest-414-08-Sept-2024
Problem B: coding75.com/dsa-cp/leetcode-contests/3281-maximize-score-of-numbers-in-ranges-weekly-contest-414-08-Sept-2024
Problem C: coding75.com/dsa-cp/leetcode-contests/3282-reach-end-of-array-with-max-score-weekly-contest-414-08-Sept-2024
Problem D: coding75.com/dsa-cp/leetcode-contests/3283-maximum-number-of-moves-to-kill-all-pawns-weekly-contest-414-08-Sept-2024
Subscribe to the channel for Amazing Coding and Competitive Programming Content.
🚀 Join Telegram for Post Contest Discussions, Coding Meets, and Important Updates, Join a Community of over 20,000+ Coders: t.me/cpabhinav
📌 Follow me on Instagram for Regular Updates: iammabhinav
📌 Join my family of 40K+ on Linkedin: www.linkedin.com/in/abhinavawasthi01/
📌 Whatsapp Channel: whatsapp.com/channel/0029Va55Idf1NCrU16kHOt3j
👉🏻 Coding Profiles
My Codeforces: codeforces.com/profile/abhinavawasthi
My Codechef: www.codechef.com/users/abhinavawasthi
My Leetcode: leetcode.com/abhinavawasthi/
👉🏻 Connect with Me
LinkTree- linktr.ee/abhinavawasthi
My LinkedIn- www.linkedin.com/in/abhinavawasthi01
My Instagram- iammabhinav
My Facebook- awasthi.abhinav.3
My Twitter- call_me_abhinav
Coding Blogs- abhinavawasthi.code.blog/
coding
programming
competitive programming
software developer
software engineer
interview preparation
interview experience
dsa
Leetcode Weekly Contest 414 Editorials
Leetcode Weekly Contest 414
Leetcode Weekly Contest 414 solutions
Maximum Number of Moves to Kill All Pawns
Maximum Number of Moves to Kill All Pawns leetcode
Maximum Number of Moves to Kill All Pawns leetcode solution
Maximum Number of Moves to Kill All Pawns leetcode editorial
Maximum Number of Moves to Kill All Pawns solution
Maximum Number of Moves to Kill All Pawns editorial
Reach End of Array With Max Score
Reach End of Array With Max Score leetcode
Reach End of Array With Max Score leetcode solution
Reach End of Array With Max Score leetcode editorial
Reach End of Array With Max Score solution
Reach End of Array With Max Score editorial
Maximize Score of Numbers in Ranges
Maximize Score of Numbers in Ranges leetcode
Maximize Score of Numbers in Ranges leetcode solution
Maximize Score of Numbers in Ranges leetcode editorial
Maximize Score of Numbers in Ranges solution
Maximize Score of Numbers in Ranges editorial
Convert Date to Binary
Convert Date to Binary leetcode
Convert Date to Binary leetcode solution
Convert Date to Binary leetcode editorial
Convert Date to Binary solution
Convert Date to Binary editorial
00:00 Introduction
02:35 Convert Date to Binary
07:30 Maximize Score of Numbers in Ranges
24:15 Reach End of Array With Max Score
30:40 Maximum Number of Moves to Kill All Pawns
59:05 Outro
Problem A: coding75.com/dsa-cp/leetcode-contests/3280-convert-date-to-binary-weekly-contest-414-08-Sept-2024
Problem B: coding75.com/dsa-cp/leetcode-contests/3281-maximize-score-of-numbers-in-ranges-weekly-contest-414-08-Sept-2024
Problem C: coding75.com/dsa-cp/leetcode-contests/3282-reach-end-of-array-with-max-score-weekly-contest-414-08-Sept-2024
Problem D: coding75.com/dsa-cp/leetcode-contests/3283-maximum-number-of-moves-to-kill-all-pawns-weekly-contest-414-08-Sept-2024
Subscribe to the channel for Amazing Coding and Competitive Programming Content.
🚀 Join Telegram for Post Contest Discussions, Coding Meets, and Important Updates, Join a Community of over 20,000+ Coders: t.me/cpabhinav
📌 Follow me on Instagram for Regular Updates: iammabhinav
📌 Join my family of 40K+ on Linkedin: www.linkedin.com/in/abhinavawasthi01/
📌 Whatsapp Channel: whatsapp.com/channel/0029Va55Idf1NCrU16kHOt3j
👉🏻 Coding Profiles
My Codeforces: codeforces.com/profile/abhinavawasthi
My Codechef: www.codechef.com/users/abhinavawasthi
My Leetcode: leetcode.com/abhinavawasthi/
👉🏻 Connect with Me
LinkTree- linktr.ee/abhinavawasthi
My LinkedIn- www.linkedin.com/in/abhinavawasthi01
My Instagram- iammabhinav
My Facebook- awasthi.abhinav.3
My Twitter- call_me_abhinav
Coding Blogs- abhinavawasthi.code.blog/
coding
programming
competitive programming
software developer
software engineer
interview preparation
interview experience
dsa
Leetcode Weekly Contest 414 Editorials
Leetcode Weekly Contest 414
Leetcode Weekly Contest 414 solutions
Maximum Number of Moves to Kill All Pawns
Maximum Number of Moves to Kill All Pawns leetcode
Maximum Number of Moves to Kill All Pawns leetcode solution
Maximum Number of Moves to Kill All Pawns leetcode editorial
Maximum Number of Moves to Kill All Pawns solution
Maximum Number of Moves to Kill All Pawns editorial
Reach End of Array With Max Score
Reach End of Array With Max Score leetcode
Reach End of Array With Max Score leetcode solution
Reach End of Array With Max Score leetcode editorial
Reach End of Array With Max Score solution
Reach End of Array With Max Score editorial
Maximize Score of Numbers in Ranges
Maximize Score of Numbers in Ranges leetcode
Maximize Score of Numbers in Ranges leetcode solution
Maximize Score of Numbers in Ranges leetcode editorial
Maximize Score of Numbers in Ranges solution
Maximize Score of Numbers in Ranges editorial
Convert Date to Binary
Convert Date to Binary leetcode
Convert Date to Binary leetcode solution
Convert Date to Binary leetcode editorial
Convert Date to Binary solution
Convert Date to Binary editorial
00:00 Introduction
02:35 Convert Date to Binary
07:30 Maximize Score of Numbers in Ranges
24:15 Reach End of Array With Max Score
30:40 Maximum Number of Moves to Kill All Pawns
59:05 Outro
Переглядів: 2 173
Відео
Leetcode Biweekly Contest 138 & Weekly Contest 413 Discussion & Editorial 🚀 | Abhinav Awasthi
Переглядів 4,2 тис.День тому
👉🏻 Live Discussion Class Link: coding75.com/classroom/live/leetcode-contests-discussion-competitive-programming-2024-09-01 👉🏻 Biweekly Contest 138: leetcode.com/contest/biweekly-contest-138/ 👉🏻 Weekly Contest 413: leetcode.com/contest/weekly-contest-413/ 👉🏻 Biweekly Contest 138 Problem Codes: Problem A: coding75.com/dsa-cp/leetcode-contests/3270-find-the-key-of-the-numbers-biweekly-contest-138-...
A-D | Leetcode Weekly Contest 412 Editorials | Count Almost Equal Pairs II | Abhinav Awasthi
Переглядів 4,9 тис.14 днів тому
Contest Link: leetcode.com/contest/weekly-contest-412/ Problem A: coding75.com/dsa-cp/leetcode-contests/3264-final-array-state-after-k-multiplication-operations-i-weekly-contest-412-25-Aug-2024 Problem B: coding75.com/dsa-cp/leetcode-contests/3265-count-almost-equal-pairs-i-weekly-contest-412-25-Aug-2024 Problem C: coding75.com/dsa-cp/leetcode-contests/3266-final-array-state-after-k-multiplicat...
A-D | Leetcode Weekly Contest 411 Solutions 🚀 | Editorials | Abhinav Awasthi
Переглядів 4,3 тис.21 день тому
Contest Link: leetcode.com/contest/weekly-contest-411/ Problem A: coding75.com/dsa-cp/leetcode-contests/3258-count-substrings-that-satisfy-k-constraint-i-weekly-contest-411-18-Aug-2024 Problem B: coding75.com/dsa-cp/leetcode-contests/3259-maximum-energy-boost-from-two-drinks-weekly-contest-411-18-Aug-2024 Problem C: coding75.com/dsa-cp/leetcode-contests/3260-find-the-largest-palindrome-divisibl...
A, B, C | Leetcode Biweekly Contest 137 Editorials | Maximum Value Sum by Placing Three Rooks
Переглядів 5 тис.21 день тому
Contest Link: leetcode.com/contest/biweekly-contest-137/ Problem A: coding75.com/dsa-cp/leetcode-contests/3254-find-the-power-of-k-size-subarrays-i-biweekly-contest-137-17-Aug-2024 Problem B: coding75.com/dsa-cp/leetcode-contests/3255-find-the-power-of-k-size-subarrays-ii-biweekly-contest-137-17-Aug-2024 Problem C: coding75.com/dsa-cp/leetcode-contests/3256-maximum-value-sum-by-placing-three-ro...
A-E | Educational Codeforces Round 169 Solutions | Not a Nim Problem | Colored Portals | Abhinav
Переглядів 2,1 тис.28 днів тому
Contest Link: codeforces.com/contest/2004 NIM Problem: en.wikipedia.org/wiki/Nim GFG: www.geeksforgeeks.org/combinatorial-game-theory-set-2-game-nim/ Problem A: coding75.com/dsa-cp/codeforces/a-closest-point-1723749114769 Problem B: coding75.com/dsa-cp/codeforces/b-game-with-doors-1723749250232 Problem C: coding75.com/dsa-cp/codeforces/c-splitting-items-1723749458128 Problem D: coding75.com/dsa...
A-E | Codechef Starters 147 Solutions | K Subsequence 101 | Non-Primes 101 | Truth Teller And Liars
Переглядів 2,6 тис.28 днів тому
Contest Link: www.codechef.com/START147B Problem A: coding75.com/dsa-cp/codechef/gold-coins-101-1723657504565 Problem B: coding75.com/dsa-cp/codechef/independence-day-101-1723657579274 Problem C: coding75.com/dsa-cp/codechef/truth-teller-and-liars-101-1723657673573 Problem D: coding75.com/dsa-cp/codechef/non-primes-101-1723657790526 Problem E: coding75.com/dsa-cp/codechef/k-subsequence-101-1723...
A-F | Codechef Starters 146 Editorials | Back Front | Bouncing Ball | Permutation Construction
Переглядів 2 тис.Місяць тому
Contest Link: www.codechef.com/START146 Problem A: coding75.com/dsa-cp/codechef/olympics-2024-1723053639770 Problem B: coding75.com/dsa-cp/codechef/no-winner-1723053742583 Problem C: coding75.com/dsa-cp/codechef/knockout-tournament-1723053844286 Problem D: coding75.com/dsa-cp/codechef/permutation-construction-1723053986098 Problem E: coding75.com/dsa-cp/codechef/bouncing-ball-1723056746534 Prob...
A-C | Leetcode Weekly Contest 409 Editorials | Shortest Distance After Road Addition Queries
Переглядів 3,5 тис.Місяць тому
Contest Link: leetcode.com/contest/weekly-contest-409/ Problem A: coding75.com/dsa-cp/leetcode-contests/3242-design-neighbor-sum-service-weekly-contest-409-04-Aug-2024 Problem B: coding75.com/dsa-cp/leetcode-contests/3243-shortest-distance-after-road-addition-queries-i-weekly-contest-409-04-Aug-2024 Problem C: coding75.com/dsa-cp/leetcode-contests/3244-shortest-distance-after-road-addition-quer...
A-D Leetcode Biweekly Contest 136 Editorials | Time Taken to Mark All Nodes | Abhinav Awasthi
Переглядів 6 тис.Місяць тому
Contest Link: leetcode.com/contest/biweekly-contest-136/ Problem A: coding75.com/dsa-cp/leetcode-contests/3238-find-the-number-of-winning-players-biweekly-contest-136-03-Aug-2024 Problem B: coding75.com/dsa-cp/leetcode-contests/3239-minimum-number-of-flips-to-make-binary-grid-palindromic-i-biweekly-contest-136-03-Aug-2024 Problem C: coding75.com/dsa-cp/leetcode-contests/3240-minimum-number-of-f...
A-D | Leetcode Weekly Contest 408 Editorials | Check if the Rectangle Corner Is Reachable | Solution
Переглядів 6 тис.Місяць тому
📌 Contest Link: leetcode.com/contest/weekly-contest-408/ Problem A: coding75.com/dsa-cp/leetcode-contests/3232-find-if-digit-game-can-be-won-weekly-contest-408-28-Jul-2024 Problem B: coding75.com/dsa-cp/leetcode-contests/3233-find-the-count-of-numbers-which-are-not-special-weekly-contest-408-28-Jul-2024 Problem C: coding75.com/dsa-cp/leetcode-contests/3234-count-the-number-of-substrings-with-do...
A-D | Leetcode Weekly Contest 407 Editorials | Minimum Operations to Make Array Equal to Target
Переглядів 2,2 тис.Місяць тому
Contest Link: leetcode.com/contest/weekly-contest-407/ Problem A: coding75.com/dsa-cp/leetcode-contests/3226-number-of-bit-changes-to-make-two-integers-equal-weekly-contest-407-21-Jul-2024 Problem B: coding75.com/dsa-cp/leetcode-contests/3227-vowels-game-in-a-string-weekly-contest-407-21-Jul-2024 Problem C: coding75.com/dsa-cp/leetcode-contests/3228-maximum-number-of-operations-to-move-ones-to-...
2751. Robot Collisions Leetcode Editorial | Problem of the Day Leetcode Solutions | Abhinav Awasthi
Переглядів 1,5 тис.2 місяці тому
Code Link: coding75.com/dsa-cp/leetcode-potd/2751-robot-collisions-13-Jul-2024 Subscribe to the channel for Amazing Coding and Competitive Programming Content. 🚀 Join Telegram for Post Contest Discussions, Coding Meets, and Important Updates, Join a Community of over 20,000 Coders: t.me/cpabhinav 📌 Follow me on Instagram for Regular Updates: iammabhinav 📌 Join my family of 40K on ...
1717. Maximum Score From Removing Substrings Leetcode Editorial | Problem of the Day Solution
Переглядів 1,9 тис.2 місяці тому
1717. Maximum Score From Removing Substrings Leetcode Editorial | Problem of the Day Solution
A-E | Codeforces Round 957 (Div. 3) Editorials | Novice's Mistake | Test of Love | Abhinav Awasthi
Переглядів 4,5 тис.2 місяці тому
A-E | Codeforces Round 957 (Div. 3) Editorials | Novice's Mistake | Test of Love | Abhinav Awasthi
1190. Reverse Substrings Between Each Pair of Parentheses Leetcode Editorial | Problem of the Day
Переглядів 1 тис.2 місяці тому
1190. Reverse Substrings Between Each Pair of Parentheses Leetcode Editorial | Problem of the Day
A-E | Codechef Starters 142 Editorials | Number Hunt | Array Removal | Abhinav Awasthi
Переглядів 2,2 тис.2 місяці тому
A-E | Codechef Starters 142 Editorials | Number Hunt | Array Removal | Abhinav Awasthi
1598. Crawler Log Folder Leetcode Editorial | Problem of the Day Leetcode Solution | Abhinav Awasthi
Переглядів 3312 місяці тому
1598. Crawler Log Folder Leetcode Editorial | Problem of the Day Leetcode Solution | Abhinav Awasthi
1701. Average Waiting Time Leetcode Editorial | Problem of the Day Solution Greedy | Abhinav Awasthi
Переглядів 4992 місяці тому
1701. Average Waiting Time Leetcode Editorial | Problem of the Day Solution Greedy | Abhinav Awasthi
A-D Codeforces Round 956 (Div 2) Solutions | Swap Dilemma Have Your Cake and Eat It Too Corner Twist
Переглядів 3,1 тис.2 місяці тому
A-D Codeforces Round 956 (Div 2) Solutions | Swap Dilemma Have Your Cake and Eat It Too Corner Twist
A-D | Leetcode Weekly Contest 405 Solutions | Editorials | Abhinav Awasthi
Переглядів 3,8 тис.2 місяці тому
A-D | Leetcode Weekly Contest 405 Solutions | Editorials | Abhinav Awasthi
A-D | Leetcode Biweekly Contest 134 Solutions | Number of Subarrays AND Value K | Alternating Groups
Переглядів 3,4 тис.2 місяці тому
A-D | Leetcode Biweekly Contest 134 Solutions | Number of Subarrays AND Value K | Alternating Groups
Opportunities for Batch 2023, 2024, 2026 🚀 | GeeksforGeeks Job-A-Thon 🔥 | Google, Microsoft Jobs
Переглядів 1,8 тис.2 місяці тому
Opportunities for Batch 2023, 2024, 2026 🚀 | GeeksforGeeks Job-A-Thon 🔥 | Google, Microsoft Jobs
523. Continuous Subarray Sum Leetcode Editorial | Problem of the Day Leetcode Solutions | Abhinav
Переглядів 8203 місяці тому
523. Continuous Subarray Sum Leetcode Editorial | Problem of the Day Leetcode Solutions | Abhinav
648. Replace Words Leetcode Editorial | Problem of the Day Leetcode Solutions | Abhinav Awasthi
Переглядів 8853 місяці тому
648. Replace Words Leetcode Editorial | Problem of the Day Leetcode Solutions | Abhinav Awasthi
A-D Codeforces Round 951 (Div. 2) Editorials | Fixing a Binary String Earning on Bets XOR Sequences
Переглядів 7 тис.3 місяці тому
A-D Codeforces Round 951 (Div. 2) Editorials | Fixing a Binary String Earning on Bets XOR Sequences
846. Hand of Straights Leetcode Editorial 🚀 | Problem of the Day Leetcode Solution | Abhinav Awasthi
Переглядів 1,3 тис.3 місяці тому
846. Hand of Straights Leetcode Editorial 🚀 | Problem of the Day Leetcode Solution | Abhinav Awasthi
A-E Codechef Starters 137 Editorials | Speedrun | Double Trouble | Large Differences | Solutions
Переглядів 4,4 тис.3 місяці тому
A-E Codechef Starters 137 Editorials | Speedrun | Double Trouble | Large Differences | Solutions
1002. Find Common Characters Leetcode Editorial 🚀 | Problem of the Day Solution | Abhinav Awasthi
Переглядів 9703 місяці тому
1002. Find Common Characters Leetcode Editorial 🚀 | Problem of the Day Solution | Abhinav Awasthi
A-E Codeforces Round 950 (Div. 3) Editorials | Permutation of Rows and Columns | GCD-sequence
Переглядів 4,8 тис.3 місяці тому
A-E Codeforces Round 950 (Div. 3) Editorials | Permutation of Rows and Columns | GCD-sequence
Explanation is Fire
as i am a beginner ,,i should start with Div 3 or Div 4 section na??
Helpful
expl for 2nd was mind-blowing, just 2-3 mins into listening and got the complete idea
I still didn't understand after watching the whole video, can you explain why we start from p = start[0] and if (p+m)<=start[i], we are reassigning p to start[i], how it's working. Time stamp - 14:50
Informative Sir
how can I join this meet
Understood
sir If input is [0,5,9] and d=2 then if we check for mid=1 according to code it is possible that 1 can be the difference and its also true that we will get difference larger than 1 as well but sir in reality there cannot be two number chosen that can give difference=1 sir please explain this why we are marking it as possible value
Bhaiya, For Q4, Can you please explain why turn is not used for memoization ? How how it is redundant ?
waiting for ur video from morning bro
Join Whatsapp Channel: whatsapp.com/channel/0029Va55Idf1NCrU16kHOt3j
great explanation for D
In 1 to 7 only 25 substring is valid but according to your code pref [7]-pref[1] =28 Is it wrong or am I
thanks
I think the last question was similar to longest palindromic substring
sir aapki explanation itni acch hei !!! Genuine fan of ur explanation
class Solution { public: int findMultiplier(int health, int power){ int m = health/power; if(health%power > 0) m += 1; return m; } long long minDamage(int power, vector<int>& damage, vector<int>& health) { int n = damage.size(); vector<pair<double, int>> nums; long long total_damage = accumulate(damage.begin(), damage.end(), 0); long long min_damage_to_bob = 0; for(int i=0; i<n; i++){ int m = findMultiplier(health[i], power); double priority = double(m) / damage[i]; // this is efficiency and min priority is best // eg: ki m = 2 and damage[i] = 4 to humko m=2 round lene pdenge or humko calc krna hai ki // ek round me kitna damage kr rha hai (means damage per round) and humko min dam consider krna h // jo ek round me km damage kr rha hoga humko uske trf jana hoga nums.push_back({priority, i}); } sort(nums.begin(), nums.end()); for(auto it:nums){ int index = it.second; int multiplier = findMultiplier(health[index], power); min_damage_to_bob += multiplier * total_damage; total_damage -= damage[index]; } return min_damage_to_bob; } };
Madar... D question mai equation kaisi nikali... Wo tera baap samjayega...>?
How can i join you on meet while upsolving
Soon I am launching a group that you can join for live discussion
Take it as a constructive criticism bro, but you need to explain & breakdown the solution as well as intuition behind the solution in a better fashion, just pasting the code an saying this is this, this is that especially for the ones where upsolving is required Q3s and Q4s.
Yes I understand, will take care of this, thanks for your suggestion
Yeh i agree with you
Mast video Abhinav Bhai ❤❤ Khair mujhe nahi pta yeh sah kya hai par comment kar diya m😅😅😅😅
Are thanks bhai
Q1 Biweekly code looks so unreadable, this is how I wrote it in contest ```class Solution { public: int generateKey(int num1, int num2, int num3) { int ans=0; int k=4; int p=0; while(k--){ int a=num1%10; int b=num2%10; int c=num3%10; num1/=10; num2/=10; num3/=10; int mn=min(min(a,b),c); ans+=mn*pow(10,p); p++; } return ans; } };``` stick to fundamentals.
Hii Sir, just puchna tha aapka koi course yaa phir sara youtube pe kyunki mera bhi logic hritu and kusharga jesa tha tle dia tha
Bhot acha explain kiya bhaiya apne Loved how you approached Biweekly Q3.
mastt hai
Bhai div 3 codeforces round 970 please 😢😢😢
great work bhaiya
👋👍👍
best for contest upsolving 💯💯
Nice
Waiting for it 😅
🙌🏻
the trick to get past the TLE error is awesome
Amazing explanation
for making all possible variation of string we can use concept of generate permutation with a baseCase of -> if(swapCnt>=2 || index>=nums.size()){ store string } then it would work same but we have clear code.
3rd qs badiya samjhaya bro
Can anyone tell why it is giving WA - class Solution { public: using ll = long long; int MOD = 1e9 + 7; ll findexp(ll base, ll exponent) { ll result = 1; while (exponent > 0) { if (exponent % 2 == 1) { result = (result * base) % MOD; } base = (base * base) % MOD; exponent /= 2; } return result; } vector<int> getFinalState(vector<int>& nums, int k, int x) { if(x==1) return nums; int n = nums.size(); int maxi = *max_element(nums.begin(), nums.end()); priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> pq; for (int i = 0; i < n; i++) { pq.push({nums[i], i}); } while (k && pq.top().first * x <= maxi) { ll t = pq.top().first; int i = pq.top().second; pq.pop(); t*=x; pq.push({t, i}); k--; } ll remainingop = k / n; ll extras = k % n; ll z = findexp(x, remainingop); // Calculate the final states for the first n elements for (int i = 0; i < n; i++) { ll t = pq.top().first; int j = pq.top().second; pq.pop(); // Carefully multiply with z and apply the modulo in a controlled manner pq.push({(1LL*z * t)%MOD, j}); } // Handle the remaining extra operations individually for (int i = 0; i < extras; i++) { ll t = pq.top().first; int j = pq.top().second; pq.pop(); ll temp = (1LL * x) % MOD; temp = (temp * t) % MOD; pq.push({temp, j}); } // Extract the final state of the array while (!pq.empty()) { ll t = pq.top().first; int i = pq.top().second; pq.pop(); nums[i] = t%MOD; } return nums; } };
Hey can any one tell why this case only passed 570 test cases, q2 class Solution { public: int length(int num){ if(num == 0) return 1; int len = 0; while(num){ len++; num /= 10; } return len; } int reverseDigits(int num) { int rev_num = 0; while (num > 0) { rev_num = rev_num * 10 + num % 10; num = num / 10; } return rev_num; } bool check (int num1, int num2){ if(num1 == num2) return true; int temp1 = num1, temp2 = num2; int cnt = 0; if(length(num1) <=2 && length(num2) <=2 ) { if(num1 == reverseDigits(num2) || num2 == reverseDigits(num1) ) return true; else return false; } while(temp1 > 0 && temp2 > 0){ int a = temp1 % 10; int b = temp2 % 10; if(a != b) cnt++; temp1 /= 10; temp2 /= 10; } while (temp1 > 0 || temp2 > 0) { cnt++; temp1 /= 10; temp2 /= 10; } if(cnt != 2) return false; return true; } int countPairs(vector<int>& nums) { int cnt = 0; for(int i = 0;i<nums.size();++i){ for(int j = i+1; j<nums.size();++j){ // if(i == j) continue; if(check(nums[i], nums[j])) cnt++; } } return cnt; } };
i guess if you can explain in Hindi only then your explanation will be better then what it is now
any java people who can provide the solution of 3 question, I tried to implement this approach but its failing on 519 case ``` java class Solution { public int[] getFinalState(int[] nums, int k, int multiplier) { if(multiplier==1)return nums; PriorityQueue<int[]> minHeap=new PriorityQueue<>((a, b)-> { if(a[0]!=b[0])return (a[0]-b[0] < 0 ? -1:1); return (a[1] - b[1]); }); int mod=1_000_000_007; int n=nums.length; int max=Integer.MIN_VALUE; for(int i=0;i<n;i++){ minHeap.offer(new int[]{nums[i], i}); max=Math.max(max, nums[i]); } while(k > 0 && (1L*multiplier*minHeap.peek()[0] <= max)){ int[] pair=minHeap.poll(); k--; minHeap.offer(new int[]{(int)((1L*pair[0]*multiplier)%mod), pair[1]}); } long pow=modPower(multiplier, k/n, mod); while(!minHeap.isEmpty()){ int[] pair=minHeap.poll(); int val=pair[0]; int index=pair[1]; if(k%n!=0){ k--; nums[index]=(int)((1L*multiplier%mod*pow%mod*val%mod)%mod); } else{ nums[index]=(int)((1L*pow%mod*val%mod)%mod); } } return nums; } public long modPower(int base, int exp, int mod){ long result=1; while(exp > 0){ if((exp&1)==1){ result=(result*base)%mod; } base=(base*base)%mod; exp>>=1; } return result; } }```
excellent explanation with quality code
(3&4) both are easy after seeing your video sir, I don't know why i am not thing of that...😢😢
Last question ka solution aisa lga jaise tle eliminator se copy paste kr diya ho 😂. But loved it
very good explanation bro,specially 3rd question
bhai 3rd question itna dhaansu smjhaya, maza aa gya thank you for the amazing explanation
class Solution { public: long long powermod(long long x, long long y, long long p){ long long res = 1; if (x == 0){return 0;} while (y > 0){ if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res; } void print (priority_queue<long long, vector<long long >, greater<long long>> heap){ for (int i=0;i<5;i++) {cout<<heap.top()<<" "; heap.pop();}cout<<endl; } vector<int> getFinalState(vector<int>& nums, int k, int multiplier) { priority_queue<long long, vector<long long>, greater<long long>> heap; for (auto p : nums) { heap.push(p); } long long mx = *max_element(nums.begin(),nums.end()); while (k && 1LL*multiplier*heap.top()<=mx){ auto it = find(nums.begin(), nums.end(), heap.top()); *it = (heap.top() * multiplier)%1000000007 ; long long top = heap.top(); heap.pop(); heap.push((top * multiplier)%1000000007 ); k--; } long long turn = k/nums.size(); long long remain = k % nums.size(); cout<<turn<<" "<<remain<<endl; while(!heap.empty()){ heap.pop(); } for (long long i = 0; i < nums.size(); i++) { // auto it = find(nums.begin(), nums.end(), heap.top()); // *it = (heap.top() * (powermod(multiplier,turn,1000000007))) % 1000000007; // long long top = heap.top(); // heap.pop(); // heap.push((top * (powermod(multiplier,turn,1000000007)))%1000000007); nums[i] = (nums[i]%1000000007* (powermod(multiplier,turn,1000000007)))%1000000007; heap.push(nums[i]); } if (remain>0){ for (long long i = 0; i < remain; i++) { long long top = heap.top(); auto it = find(nums.begin(), nums.end(), top); *it = (top * multiplier) % 1000000007; heap.pop(); heap.push((top * multiplier) % 1000000007); }} // [66307295,441787703,589039035,322281864] // 900900704 // 641725 return nums; } }; nums = [889458628,338743558,875422936,684907163,233489834] k = 246181588 multiplier = 313380 stucked at test case 522 i had little bit diff sol please chek it
same bro failing somewhere in 500th tetst case
amazing
My question is for the 4th one. for every digit we are checking after 0th, 1st, 2nd swap they are previously present in the map or not and before that we are storing them in set(all unique ones). But here we are checking 0th swap on i with 0th,1st , 2nd swap on j element with the help of map. But what about 1st swap on i with 0th,1st,2nd(not 2nd because we are swaping ith element one time) swap on j....and like that 1|0 combination and 2|0 combination and 1|1 combination. I hope my questions are clear to you. How are you considering those conditions
Nice 😊
Great explanation of Q3. Watched many videos, but was unable to understand. Finally understood from ur video.
in first while loop in 3rd question you are not poping the top element why this will not give tle??