TLE Eliminators - by Priyansh
TLE Eliminators - by Priyansh
  • 248
  • 1 034 353
Codeforces Round 968 (Div 2) | Video Solutions - A to D1 | by Harsh Gupta | TLE Eliminators
Here are the video solutions in the form of a post-contest discussion for problems A, B, C, D1 of Codeforces Round 968 (Div 2). The live discussion was done with students of TLE Eliminators, this is the recording of the same. We hope this will be useful for you in up-solving this contest.
📢Check out handpicked problems by Priyansh himself, on our CP-31 sheet: www.tle-eliminators.com/cp-sheet
Solution Codes:
Turtle and Good Strings: codeforces.com/contest/2003/submission/278157987
Turtle and Piggy Are Playing a Game 2: codeforces.com/contest/2003/submission/278158290
Turtle and Good Pairs: codeforces.com/contest/2003/submission/278158438
Turtle and a MEX Problem (Easy Version): codeforces.com/contest/2003/submission/278158594
Be sure to check out TLE Eliminators.
Website: www.tle-eliminators.com/
Instagram: tle_eliminators
Linkedin: www.linkedin.com/company/tle-eliminators
Twitter: TLE_Eliminators
TLE Community Discord Server: discord.gg/xmTtS4XdJw
Timestamps:-
0:00 Problem A
7:33 Problem B
21:24 Problem C
42:10 Problem D
Переглядів: 2 924

Відео

Leetcode Weekly Contest 412 | Video Solutions - A to D | by Viraj Chandra | TLE Eliminators
Переглядів 2,8 тис.4 години тому
Here are the video solutions for problems A, B, C, D of Leetcode Weekly Contest 412. We hope this will be useful for you in up-solving this contest. 📢Check out handpicked problems by Priyansh himself, on our CP-31 sheet: www.tle-eliminators.com/cp-sheet Solution Codes: Final Array State After K Multiplication Operations I - ideone.com/caDkG7 Count Almost Equal Pairs I - ideone.com/Qm04Xa Final ...
Codechef Starters 148 | Video Solutions - A to F | by Subhankar Banerjee | TLE Eliminators
Переглядів 3,4 тис.14 годин тому
Here are the video solutions in the form of a post-contest discussion for problems A, B, C, D, E, F of Codechef Starters 148 (Div 4). The live discussion was done with students of TLE Eliminators, this is the recording of the same. We hope this will be useful for you in up-solving this contest. 📢Check out handpicked problems by Priyansh himself, on our CP-31 sheet: www.tle-eliminators.com/cp-sh...
Codeforces Round 967 (Div 2) | Video Solutions - A to D | by Gaurish Baliga | TLE Eliminators
Переглядів 3,9 тис.16 годин тому
Here are the video solutions in the form of a post-contest discussion for problems A, B, C, D of Codeforces Round 967 (Div 2). The live discussion was done with students of TLE Eliminators, this is the recording of the same. We hope this will be useful for you in up-solving this contest. 📢Check out handpicked problems by Priyansh himself, on our CP-31 sheet: www.tle-eliminators.com/cp-sheet Sol...
Leetcode Weekly Contest 411 | Video Solutions - A to D | by Viraj Chandra | TLE Eliminators
Переглядів 1,8 тис.19 годин тому
Here are the video solutions for problems A, B, C, D of Leetcode Weekly Contest 411. We hope this will be useful for you in up-solving this contest. 📢Check out handpicked problems by Priyansh himself, on our CP-31 sheet: www.tle-eliminators.com/cp-sheet Solution Codes: Count Substrings That Satisfy K-Constraint I: leetcode.com/problems/count-substrings-that-satisfy-k-constraint-i/submissions/13...
Educational Codeforces Round 169 | Video Solutions - A to D | by Abhinav Kumar | TLE Eliminators
Переглядів 3,4 тис.День тому
Here are the video solutions in the form of a post-contest discussion for problems A, B, C, D of Educational Codeforces Round 169. The live discussion was done with students of TLE Eliminators, this is the recording of the same. We hope this will be useful for you in up-solving this contest. 📢Check out handpicked problems by Priyansh himself, on our CP-31 sheet: www.tle-eliminators.com/cp-sheet...
Codechef Starters 147 | Video Solutions - A to E | by Harsh Gupta | TLE Eliminators
Переглядів 2,5 тис.День тому
Here are the video solutions in the form of a post-contest discussion for problems A, B, C, D, E of Codechef Starters 147 (Div 2). The live discussion was done with students of TLE Eliminators, this is the recording of the same. We hope this will be useful for you in up-solving this contest. 📢Check out handpicked problems by Priyansh himself, on our CP-31 sheet: www.tle-eliminators.com/cp-sheet...
Codeforces Round 966 (Div 3) | Video Solutions - A to F | by Subhankar Banerjee | TLE Eliminators
Переглядів 4,9 тис.14 днів тому
Here are the video solutions in the form of a post-contest discussion for problems A, B, C, D, E, F of Codeforces Round 966 (Div 3). The live discussion was done with students of TLE Eliminators, this is the recording of the same. We hope this will be useful for you in up-solving this contest. 📢Check out handpicked problems by Priyansh himself, on our CP-31 sheet: www.tle-eliminators.com/cp-she...
Codeforces Round EPIC Round | Video Solutions - A to D1 | by Abhinav Kumar | TLE Eliminators
Переглядів 2,9 тис.14 днів тому
Here are the video solutions in the form of a post-contest discussion for problems A, B, C, D1 of Codeforces EPIC Round. The live discussion was done with students of TLE Eliminators, this is the recording of the same. We hope this will be useful for you in up-solving this contest. 📢Check out handpicked problems by Priyansh himself, on our CP-31 sheet: www.tle-eliminators.com/cp-sheet Solution ...
Leetcode Weekly Contest 410 | Video Solutions - A to D | by Viraj Chandra | TLE Eliminators
Переглядів 4,4 тис.14 днів тому
Here are the video solutions for problems A, B, C of Leetcode Weekly Contest 410. We hope this will be useful for you in up-solving this contest. 📢Check out handpicked problems by Priyansh himself, on our CP-31 sheet: www.tle-eliminators.com/cp-sheet Solution Codes: Snake in Matrix: leetcode.com/problems/snake-in-matrix/submissions/1351712302/ Count the Number of Good Nodes: leetcode.com/proble...
Codeforces Round 965 (Div 2) | Video Solutions - A to D | by Abhinav Kumar | TLE Eliminators
Переглядів 4,5 тис.14 днів тому
Here are the video solutions in the form of a post-contest discussion for problems A, B, C, D of Codeforces Round 965 (Div 2). The live discussion was done with students of TLE Eliminators, this is the recording of the same. We hope this will be useful for you in up-solving this contest. 📢Check out handpicked problems by Priyansh himself, on our CP-31 sheet: www.tle-eliminators.com/cp-sheet Sol...
Codechef Starters 146 | Video Solutions - A to D | by Harsh Gupta | TLE Eliminators
Переглядів 2,5 тис.14 днів тому
Here are the video solutions in the form of a post-contest discussion for problems A, B, C, D of Codechef Starters 146 (Div 2). The live discussion was done with students of TLE Eliminators, this is the recording of the same. We hope this will be useful for you in up-solving this contest. 📢Check out handpicked problems by Priyansh himself, on our CP-31 sheet: www.tle-eliminators.com/cp-sheet So...
Codeforces Round 964 (Div 4) | Video Solutions - A to G2 | by Abhinav Kumar | TLE Eliminators
Переглядів 5 тис.21 день тому
Here are the video solutions in the form of a post-contest discussion for problems A, B, C, D, E, F, G1, G2 of Codeforces Round 964 (Div 4). The live discussion was done with students of TLE Eliminators, this is the recording of the same. We hope this will be useful for you in up-solving this contest. 📢Check out handpicked problems by Priyansh himself, on our CP-31 sheet: www.tle-eliminators.co...
Codeforces Round 963 | Video Solutions - A to C | by Harsh Gupta | TLE Eliminators
Переглядів 3,8 тис.21 день тому
Here are the video solutions in the form of a post-contest discussion for problems A, B, C of Codeforces Round 963 (Div 2). The live discussion was done with students of TLE Eliminators, this is the recording of the same. We hope this will be useful for you in up-solving this contest. 📢Check out handpicked problems by Priyansh himself, on our CP-31 sheet: www.tle-eliminators.com/cp-sheet Soluti...
Leetcode Weekly Contest 409 | Video Solutions - A to C | by Harsh Gupta | TLE Eliminators
Переглядів 2,2 тис.21 день тому
Here are the video solutions for problems A, B, C of Leetcode Weekly Contest 409. We hope this will be useful for you in up-solving this contest. 📢Check out handpicked problems by Priyansh himself, on our CP-31 sheet: www.tle-eliminators.com/cp-sheet Solution Codes: Design Neighbor Sum Service: leetcode.com/contest/weekly-contest-409/submissions/detail/1343684113/ Shortest Distance After Road A...
Codechef Starters 145 | Video Solutions - A to D | by Harsh Gupta | TLE Eliminators
Переглядів 3,8 тис.21 день тому
Codechef Starters 145 | Video Solutions - A to D | by Harsh Gupta | TLE Eliminators
Educational Codeforces Round 168 | Video Solutions - A to D | by Harsh Gupta | TLE Eliminators
Переглядів 4,1 тис.28 днів тому
Educational Codeforces Round 168 | Video Solutions - A to D | by Harsh Gupta | TLE Eliminators
Pinely Round 4 | Video Solutions - A to E | by Harsh Gupta | TLE Eliminators
Переглядів 2,5 тис.28 днів тому
Pinely Round 4 | Video Solutions - A to E | by Harsh Gupta | TLE Eliminators
Free Access To Our Course Helped Kunal Get To Expert | Kunal Shaw | Student Testimonial
Переглядів 1,9 тис.28 днів тому
Free Access To Our Course Helped Kunal Get To Expert | Kunal Shaw | Student Testimonial
Leetcode Weekly Contest 408 | Video Solutions - A to D | by Harsh Gupta | TLE Eliminators
Переглядів 4,5 тис.28 днів тому
Leetcode Weekly Contest 408 | Video Solutions - A to D | by Harsh Gupta | TLE Eliminators
Codeforces Round 962 | Video Solutions - A to F | by Raghav Goel | TLE Eliminators
Переглядів 4,2 тис.Місяць тому
Codeforces Round 962 | Video Solutions - A to F | by Raghav Goel | TLE Eliminators
How to choose the right level at TLE Eliminators?
Переглядів 2,2 тис.Місяць тому
How to choose the right level at TLE Eliminators?
How our student got to Expert | Yash Pratap Singh | Student Testimonials
Переглядів 3,8 тис.Місяць тому
How our student got to Expert | Yash Pratap Singh | Student Testimonials
Codechef Starters 144 | Video Solutions - A to D | by Harsh Gupta | TLE Eliminators
Переглядів 2,6 тис.Місяць тому
Codechef Starters 144 | Video Solutions - A to D | by Harsh Gupta | TLE Eliminators
Codeforces Round 961 | Video Solutions - A to B2 | by Harsh Gupta | TLE Eliminators
Переглядів 3 тис.Місяць тому
Codeforces Round 961 | Video Solutions - A to B2 | by Harsh Gupta | TLE Eliminators
Leetcode Weekly Contest 407 | Video Solutions - A to D | by Viraj Chandra| TLE Eliminators
Переглядів 2,4 тис.Місяць тому
Leetcode Weekly Contest 407 | Video Solutions - A to D | by Viraj Chandra| TLE Eliminators
Codeforces Round 960 | Video Solutions - A to D | by Raghav Goel | TLE Eliminators
Переглядів 3,5 тис.Місяць тому
Codeforces Round 960 | Video Solutions - A to D | by Raghav Goel | TLE Eliminators
Level 3 | TLE Eliminators | Competitive Programming Course
Переглядів 1,8 тис.Місяць тому
Level 3 | TLE Eliminators | Competitive Programming Course
Level 4 | TLE Eliminators | Competitive Programming Course
Переглядів 1,6 тис.Місяць тому
Level 4 | TLE Eliminators | Competitive Programming Course
Level 2 | TLE Eliminators | Competitive Programming Course
Переглядів 1,8 тис.Місяць тому
Level 2 | TLE Eliminators | Competitive Programming Course

КОМЕНТАРІ

  • @grandparick3176
    @grandparick3176 6 годин тому

    In problem D1, it says you start with some element X but what exactly is that X? We don't really take anything X as input so how do we exactly guess what x to take?

  • @aditisingh-km1nf
    @aditisingh-km1nf 13 годин тому

    when will tle 12.0 be released?

  • @user-ih4jr8iz2q
    @user-ih4jr8iz2q День тому

    sir you are best teacher a well as the guider to help in the journey of cp and dsa salute to you please make video on all the contest solved by your idea

  • @39_jatinjain4
    @39_jatinjain4 День тому

    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; } };

  • @gigachad2419
    @gigachad2419 День тому

    Loved D!!

  • @raghavgoel4255
    @raghavgoel4255 День тому

    What is the codeforces handle of Abhinav?

  • @shadanhussain5107
    @shadanhussain5107 День тому

    4th question ♥♥

  • @vysaivicky4724
    @vysaivicky4724 День тому

    Can I start cp with Java also?

  • @HarshitGupta-i7s
    @HarshitGupta-i7s День тому

    Great video !

  • @Ramneet04
    @Ramneet04 День тому

    But what's the time complexity for D1? HOW N*L WORKS?

    • @MATRIX-404
      @MATRIX-404 День тому

      Because it is given that some of lengths of all sequences does not exceed 2*1e5

    • @Ramneet04
      @Ramneet04 День тому

      @@MATRIX-404 oh thanks 👍

  • @Jv_Singh37
    @Jv_Singh37 День тому

    22:32 🤣🤣🤣😁

  • @priyanshkumar_iitd
    @priyanshkumar_iitd День тому

    Awesome solution for D1 🔥Thanks Harsh Sir

  • @haryannvi-coder
    @haryannvi-coder День тому

    good explanation viraj 👏👏

  • @uttamkumarreddygaggenapall2070

    what is ans for D1 for below testcase. 2 0 1 0 2 0 3 3 50 1 2 3 1 2 3 4 0 1 2 3 And also ans to this.

    • @shivamkumar5857
      @shivamkumar5857 День тому

      For the first case its 2 as we can use 1st sequence and then we use second sequence

    • @adityasingh6294
      @adityasingh6294 День тому

      For the second it will be 1290 because the max mex can be 5 so for f(0) to f(4) sum all 5 then sum all the no from 5+6+7+8.......50=1290

  • @anuragbandyopadhyay3483
    @anuragbandyopadhyay3483 2 дні тому

    Great, Harsh bhai.

  • @user-dk3pv4zi2s
    @user-dk3pv4zi2s 2 дні тому

    Super 🎉

  • @coder_07
    @coder_07 2 дні тому

    Thanks @VraijChandra

  • @harshtank7075
    @harshtank7075 2 дні тому

    Great Explanation for D1

  • @aankie
    @aankie 2 дні тому

    I think c explaining without the intuition is not worthy

  • @vishalgupta7522
    @vishalgupta7522 2 дні тому

    I couldn't even solve A 😢

    • @vishalgupta7522
      @vishalgupta7522 2 дні тому

      I thought of palindrome if palindrome then it is not a good string otherwise it is

  • @ancycoding
    @ancycoding 2 дні тому

    Beautifully Explained D1........ very simple explanation like Abhinav

  • @the_ved11
    @the_ved11 2 дні тому

    Thanks Bro. Amazing

  • @sova6330
    @sova6330 2 дні тому

    GUESSFORCES

    • @user-nt8cn3pp5f
      @user-nt8cn3pp5f 2 дні тому

      can relate , aagar 2nd wale question mai koi sirf test cases dekh leta aache se to use pta lag jata ki sort karke mid one is the answer . without any fucking logic

    • @adityathakur8695
      @adityathakur8695 День тому

      @@user-nt8cn3pp5f bro this came up into my mind but i couldn't implement it during contest

  • @adnanshahriar4062
    @adnanshahriar4062 2 дні тому

    Can anyone please tell me the rating of D1

  • @shreyanshjain1595
    @shreyanshjain1595 2 дні тому

    VERY GOOD EXPLANATION OF ALL THE FOUR PROBLEMS

  • @der05ka1ser
    @der05ka1ser 2 дні тому

    how are you so patient harsh.. loved every bit of it..

  • @user-vy4yu6oi2p
    @user-vy4yu6oi2p 2 дні тому

    bro i hate myself for missing that (possibly zero), saddest that has happened to me in this contest

  • @TLE_Eliminators
    @TLE_Eliminators 2 дні тому

    Please fill the Feedback form for PCD: forms.gle/Q9rYp52PBmAbSxau6

  • @saimaripala-0638
    @saimaripala-0638 2 дні тому

    3 explanation was 🔥

  • @akashsonar6332
    @akashsonar6332 2 дні тому

    Whew! I wounder how he made it to the observation.

  • @Sunil-cc1ei
    @Sunil-cc1ei 2 дні тому

    Best tutor at tle.

  • @ITSuyashTiwari
    @ITSuyashTiwari 2 дні тому

    got 3rd problem very clearly

  • @rajchinagundi7498
    @rajchinagundi7498 2 дні тому

    How is the initial state achieved? (1LL*multiplier*pq.top().first)%mod)<mx you are doing suppose we have array [2,1,3,5,6] and k=5 and m=4 my min heap will have 1(at top) 1*4=4 you push it into the pq & mx=6 1,(2,3,5,6,4) , you pop 1 2(3,5,6,4) ,multiply 2*4=8 & mx=6 it breaks here, but all elements are not multiplied by multiplier at least once Please explain, at least dry run the code that you write with a given example!

    • @priyanshuthapliyal104
      @priyanshuthapliyal104 2 дні тому

      ### **Initial Setup:** - **Array:** `[2, 1, 3, 5, 6]` - **k:** `5` - **multiplier:** `4` - **mod:** `1e9 + 7` - **n:** `5` (size of the array) ### **Step 1: Calculate Maximum Element** - **Maximum element (`maxi`):** `6` ### **Step 2: Build Initial Priority Queue** We create a min-heap using a priority queue: - After inserting all elements, the priority queue looks like this (based on the min-heap property): ``` pq: [(1, 1), (2, 0), (3, 2), (5, 3), (6, 4)] ``` ### **Step 3: Process the Queue for `k` Operations** We start multiplying the minimum element until the condition `(1LL * multiplier * pq.top().first) <= maxi` fails or `k` becomes zero. - **1st Iteration:** - **Top element:** `1` at index `1`. - **Multiplication:** `1 * 4 = 4` - **Update Priority Queue:** - Remove `1`, insert `4` at index `1`. - New `k = 4`. - Priority Queue: ``` pq: [(2, 0), (4, 1), (3, 2), (6, 4), (5, 3)] ``` - **2nd Iteration:** - **Top element:** `2` at index `0`. - **Multiplication:** `2 * 4 = 8` - **Condition Check:** `(1LL * 4 * 2) = 8 > 6` - The condition fails, so the loop terminates immediately. **`k` remains `4`** because the loop didn't perform any operation. ### **Step 4: Calculate Power** - **Calculate Power:** `pow = modPower(4, k/n) = modPower(4, 4/5)`. - **pow = modPower(4, 0) = 1** (integer division `4/5` gives `0`). ### **Step 5: Apply Remaining Multiplications** The remainder of `k` (i.e., `k % n = 4 % 5 = 4`) means we multiply the next `4` elements by `4` directly. - **Remaining `k = 4`, so we multiply the smallest `4` elements:** - **1st Pop:** - **Value:** `2` at index `0`. - **Result:** `nums[0] = 2 * 4 = 8` - **Priority Queue:** ``` pq: [(3, 2), (4, 1), (5, 3), (6, 4)] ``` - **2nd Pop:** - **Value:** `3` at index `2`. - **Result:** `nums[2] = 3 * 4 = 12` - **Priority Queue:** ``` pq: [(4, 1), (6, 4), (5, 3)] ``` - **3rd Pop:** - **Value:** `4` at index `1`. - **Result:** `nums[1] = 4 * 4 = 16` - **Priority Queue:** ``` pq: [(5, 3), (6, 4)] ``` - **4th Pop:** - **Value:** `5` at index `3`. - **Result:** `nums[3] = 5 * 4 = 20` - **Priority Queue:** ``` pq: [(6, 4)] ``` ### **Step 6: Final Array Construction** Now, only one element (`6`) remains unmodified. - **Final State of the Array:** ``` nums = [8, 16, 12, 20, 6] ``` ### **Summary:** - **Initial k:** `5` - **k after the first loop:** `4` - **Second iteration condition fails, so `k` remains `4`.** The final array is `[8, 16, 12, 20, 6]`. The approach correctly handles the scenario where no further operations can be performed, ensuring that `k` is only reduced when an operation is actually executed.

    • @rajchinagundi7498
      @rajchinagundi7498 День тому

      @@priyanshuthapliyal104 your second iteration, does not satisfy his initial state statment, where the multiplier is said to multiply all the elements atleast once

    • @apputadhiyal9451
      @apputadhiyal9451 12 годин тому

      @@rajchinagundi7498 Did you find out why is it working?

    • @apputadhiyal9451
      @apputadhiyal9451 11 годин тому

      Actually the multiplication becomes circular after as soon as min*multiplier exceeds mx, not necessarily until each element is multiplied at least once! Eg=> assume multiplier = 2 0 [1, 2, 3] (initially array) 1 [2, 2, 3] 2 [4,2,3] 3 [4, 4, 3] 4 [4, 4, 6] 5 [8, 4, 6] 6 [8, 8, 6] 7 [8, 8, 12] ... notice after 1 where min in array is 2, 2*2 > 3 so we came out of the first loop . now see that [k=4] is 2*[k=1] and [k=7] is 2*[k =4] this will continue so the multiplication became circular from k=1 itself not from 4. hence the condition pq.top().first * multiplier <= mx is correct.

  • @nagarjundevulapalli8624
    @nagarjundevulapalli8624 2 дні тому

    Difficult to understand, need some more effective explanation

  • @rajchinagundi7498
    @rajchinagundi7498 2 дні тому

    I feel brute force for question 2 could have been done in a simpler way, reducing its space complexity ``` class Solution { public: bool swapCheck(int a,int b){ string x=to_string(a); string y=to_string(b); int count=0; for(int i=0;i<y.length()-1;i++){ for(int j=i+1;j<y.length();j++){ string temp=y; swap(temp[i],temp[j]); if(stoi(temp)==stoi(x)){ return true; } } } return false; } int countPairs(vector<int>& nums) { int count=0; for(int i=0;i<nums.size()-1;i++){ for(int j=i+1;j<nums.size();j++){ if(nums[i]==nums[j]){ count++; cout<<nums[i]<<","<<nums[j]<<" "; continue; } if(swapCheck(nums[i],nums[j])||swapCheck(nums[j],nums[i])){ count++; cout<<nums[i]<<","<<nums[j]<<" "; } } } return count; } }; ``` During the swap itself, just check if you its a possible same string

  • @adityacr7407
    @adityacr7407 2 дні тому

    In B , we can simplify the process : CHECK THIS OUT class Solution { public: bool swapit(int i, int j, vector<int> &nums) { string str1 = to_string(nums[i]); string str2 = to_string(nums[j]); while(str1.size()>str2.size()) str2 = '0' + str2; while(str1.size()<str2.size()) str1 = '0' + str1; if(str1 == str2) return true; unordered_set<string> set; for(int i=0;i<str2.size();i++){ for(int j=i+1;j<str2.size();j++){ swap(str2[i],str2[j]); set.insert(str2); swap(str2[i],str2[j]); } } if(set.find(str1)!=set.end()) return true; return false; } int countPairs(vector<int>& nums) { int n = nums.size(); int ans = 0; for(int i=0;i<n;i++){ for(int j=i+1;j<n;j++){ if(swapit(i,j,nums)) ans++; } } return ans; } }; CHECK THIS OUT

  • @YashwanthsaiCh
    @YashwanthsaiCh 2 дні тому

    bhai tu hi CF and CC contests ka videos bana...bahut acccha seekhatha hai :)

    • @VirajChandra
      @VirajChandra 2 дні тому

      Thankyou bhai!

    • @arl0817osho
      @arl0817osho День тому

      @@VirajChandra sch m esa lgta h ki kitna easy tha question jb smjhate ho bhaiya aap

  • @Shivam-yp8xq
    @Shivam-yp8xq 2 дні тому

    Sir, in the code from line 28-34 how are we ensuring that we are multiplying the element which has least index among all the similar numbers(if there are) ?

    • @VirajChandra
      @VirajChandra 2 дні тому

      Since priority queue is made from a pair, second index is also maintained.

  • @Ramneet04
    @Ramneet04 2 дні тому

    What's the time complexity for D problem??

  • @vickyroy3595
    @vickyroy3595 2 дні тому

    @viraj please check my code , adding trailing zeroesa nd comparing class Solution { public: int countPairs(vector<int>& nums) { int n=nums.size(); int ans=0; for(int i=0;i<n;i++) { for(int j=i+1;j<n;j++) { string a=to_string(nums[i]); string b=to_string(nums[j]); if(a.size()>b.size()) { int ex=a.size()-b.size(); string z=""; for(int k=0;k<ex;k++) z+='0'; b=z+b; } else if(b.size()>a.size()) { int ex=b.size()-a.size(); string z=""; for(int k=0;k<ex;k++) z+='0'; a=z+a; } int ml=a.size(); int l=0; int c=0; unordered_map<char,int>m1,m2; while(l<ml ) { if(a[l]!=b[l]) c++; m1[a[l]]++; m2[b[l]]++; l++; } if((c==2 || c==0) && (m1==m2)) ans++; } } return ans; } };

  • @Jv_Singh37
    @Jv_Singh37 2 дні тому

    good explanation of time complexity

  • @akshatsharma5426
    @akshatsharma5426 2 дні тому

    this is how I solved problem C in O(N) #include<iostream> #include<vector> #include<algorithm> #include<cmath> #include<set> #include<map> #include<climits> #include<string> #include<queue> #define ll long long int using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int t=1; cin>>t; while(t--){ ll n,k; cin>>n>>k; vector<ll>v(n); ll check=LLONG_MIN; for(int i=0;i<n;i++){ cin>>v[i]; check=max(check,v[i]); } //sort(v.begin(),v.end()); //ll check=v[n-1]; ll maxi=-1; for(int i=0;i<n;i++){ ll n=check-v[i]; ll q=n/k; if(q%2==1){ maxi=max(maxi,k-(n%k)); } } if(maxi==-1){ cout<<check<<endl; continue; } check=check+maxi; maxi=-1; for(int i=0;i<n;i++){ ll n=check-v[i]; ll q=n/k; if(q%2==1){ maxi=max(maxi,k-(n%k)); } } if(maxi==-1){ cout<<check<<endl; continue; } cout<<-1<<endl; } }

  • @TLE_Eliminators
    @TLE_Eliminators 2 дні тому

    Please fill the Feedback form for PCD: forms.gle/tKfrRNnejeuZfUSt8

  • @shanvi_ojha
    @shanvi_ojha 2 дні тому

    Runtime error on test 8 problem c

  • @antak28
    @antak28 3 дні тому

    Plz combine all levels

  • @ankitris5201
    @ankitris5201 3 дні тому

    at 46:40 88%3 == 1

  • @akshatsharma5426
    @akshatsharma5426 3 дні тому

    I thought of the same approach for D but could not implement it

  • @krishAuras
    @krishAuras 3 дні тому

    In Problem D, the time complexity for doing this goes same that is log(n) to insert each element in the multiset. Then what's the reason behind for this approach working?