A-D | Leetcode Weekly Contest 412 Editorials | Count Almost Equal Pairs II | Abhinav Awasthi

แชร์
ฝัง
  • เผยแพร่เมื่อ 26 ต.ค. 2024

ความคิดเห็น • 33

  • @tusharsinghal1333
    @tusharsinghal1333 2 หลายเดือนก่อน +3

    bhai 3rd question itna dhaansu smjhaya, maza aa gya
    thank you for the amazing explanation

  • @sahilshrivastava6455
    @sahilshrivastava6455 2 หลายเดือนก่อน

    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.

  • @harshitgupta2909
    @harshitgupta2909 2 หลายเดือนก่อน +7

    Sir, dont make us understood on code , try to explain on the smart board,dry run and all it wiil be very helpful for us ,i like this channel i will subscribe it

  • @sureshchelani7497
    @sureshchelani7497 2 หลายเดือนก่อน +2

    (3&4) both are easy after seeing your video sir, I don't know why i am not thing of that...😢😢

  • @amitguptapc
    @amitguptapc 2 หลายเดือนก่อน

    Great explanation of Q3. Watched many videos, but was unable to understand. Finally understood from ur video.

  • @tanmoysaha8994
    @tanmoysaha8994 2 หลายเดือนก่อน

    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

  • @naveenchhipa7524
    @naveenchhipa7524 2 หลายเดือนก่อน

    very good explanation bro,specially 3rd question

  • @ankitghosh9873
    @ankitghosh9873 2 หลายเดือนก่อน

    Amazing explanation

  • @sajal..saraf...2455
    @sajal..saraf...2455 2 หลายเดือนก่อน

    excellent explanation with quality code

  • @PramodKumar-bu2uf
    @PramodKumar-bu2uf 2 หลายเดือนก่อน +3

    amazing explantion 🙂

  • @ameysawant2301
    @ameysawant2301 หลายเดือนก่อน

    Understood

  • @jaintrisisters3743
    @jaintrisisters3743 2 หลายเดือนก่อน +2

    Nice explanation abhinav

  • @Rajdweep
    @Rajdweep 2 หลายเดือนก่อน

    3rd qs badiya samjhaya bro

  • @jagan5785
    @jagan5785 2 หลายเดือนก่อน

    in first while loop in 3rd question you are not poping the top element why this will not give tle??

  • @the_ved11
    @the_ved11 2 หลายเดือนก่อน +2

    Great code, Man

  • @39_jatinjain4
    @39_jatinjain4 2 หลายเดือนก่อน

    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 getFinalState(vector& nums, int k, int x) {
    if(x==1) return nums;
    int n = nums.size();
    int maxi = *max_element(nums.begin(), nums.end());
    priority_queue pq;
    for (int i = 0; i < n; i++) {
    pq.push({nums[i], i});
    }
    while (k && pq.top().first * x

  • @gauravpunia4527
    @gauravpunia4527 2 หลายเดือนก่อน

    class Solution {
    public:
    void solve(string st,unordered_map&mp,unordered_set&s,int count)
    {
    if(count==2)return;
    for(int i = 0; i < st.size(); i++){
    for(int j = i+1; j < st.size(); j++){
    swap(st[j],st[i]);
    int number = stoi(st);
    if(s.find(number)==s.end())
    {
    mp[number]++;
    s.insert(number);
    }
    solve(st,mp,s,count+1);
    swap(st[j],st[i]);
    }
    }
    }
    int countPairs(vector& nums) {
    unordered_mapmp;
    int count = 0;
    sort(nums.begin(),nums.end());
    reverse(nums.begin(),nums.end());

    for(auto it : nums){
    count+=mp[it];
    string st = to_string(it);
    mp[it]++;
    unordered_sets;
    s.insert(it);
    solve(st,mp,s,0);
    }
    return count;
    }
    };

  • @AqibAli-te2fi
    @AqibAli-te2fi 2 หลายเดือนก่อน

    amazing

  • @sarthakjaiswal7732
    @sarthakjaiswal7732 2 หลายเดือนก่อน

    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 heap){
    for (int i=0;i

    • @SherlockHolmes-di2yr
      @SherlockHolmes-di2yr 2 หลายเดือนก่อน

      same bro failing somewhere in 500th tetst case

  • @sagarathani2729
    @sagarathani2729 2 หลายเดือนก่อน

    Nice 😊

  • @PewarDesi
    @PewarDesi 2 หลายเดือนก่อน

    Last question ka solution aisa lga jaise tle eliminator se copy paste kr diya ho 😂. But loved it

  • @idiomz4104
    @idiomz4104 2 หลายเดือนก่อน

    gg, but please try to keep the handwriting more legible. had a hardtime reading some of the digits in q3 solution.

  • @aniketsharma5003
    @aniketsharma5003 2 หลายเดือนก่อน

    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) 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& nums) {
    int cnt = 0;
    for(int i = 0;i

  • @hiteshpatwal9688
    @hiteshpatwal9688 2 หลายเดือนก่อน +1

    Nice

  • @tanmoysaha8994
    @tanmoysaha8994 2 หลายเดือนก่อน

    Waiting for 4 hours when we gonna upload videos and I can upsolve the remaining ones. 😅😅

  • @abhinavdonthula9344
    @abhinavdonthula9344 2 หลายเดือนก่อน

    why brute force in q2 works can anyone give explanation?

    • @vickyroy3595
      @vickyroy3595 2 หลายเดือนก่อน

      Constraints are low

  • @ankit_yadav11
    @ankit_yadav11 2 หลายเดือนก่อน

    Bhai Mera only 560 test cases pass hua pq min heap lagaya tha

  • @prantobala8505
    @prantobala8505 2 หลายเดือนก่อน

    don't stop !

  • @satendra6200
    @satendra6200 2 หลายเดือนก่อน +2

    i guess if you can explain in Hindi only then your explanation will be better then what it is now