3267. Count Almost Equal Pairs II | Weekly Leetcode 412

Поделиться
HTML-код
  • Опубликовано: 5 ноя 2024

Комментарии • 12

  • @shivamchaudhary7574
    @shivamchaudhary7574 2 месяца назад

    Great explanation

  • @dawodujohnson
    @dawodujohnson 2 месяца назад

    Perfect explanation by the way

  • @nabhirajjain6773
    @nabhirajjain6773 2 месяца назад

    very nice and clear explanation , thanks :)

  • @chiragbaliyan734
    @chiragbaliyan734 2 месяца назад

    leetcode weekly contest 411 ques D, can you discuss please

  • @vamsikrishnagannamaneni912
    @vamsikrishnagannamaneni912 2 месяца назад

    Well made video

  • @dawodujohnson
    @dawodujohnson 2 месяца назад

    Can we solve it using disjoint set?
    Really tried hard but failed at 604/630

    • @codingmohan
      @codingmohan  2 месяца назад

      What was your approach?

    • @dawodujohnson
      @dawodujohnson 2 месяца назад

      @codingmohan I did a double for loop for all possible pairs of numbers in nums as stated in the question. Then, I used a checker function (x,y) which increments my answer by 1 if it's true.
      Now, what my checker function does is to initialize a disjoint set of size 7, iterates through the numbers while comparing them at each position. If they are different and don't belong to the same parent, then I united them
      E.g (4598, 5489)
      4 and 5 is different and so I merge them
      5 and 4 is different but they already belong to the same group
      9 and 8 is different so I merge
      8 and 9 is different but they are already merged so I skip
      I know the approach is buggy but I was wondering why disjoint set won't work

    • @ujjwalagnihotri5001
      @ujjwalagnihotri5001 Месяц назад

      @@dawodujohnson amazing idea bro , how did you incremented your ans then, perhaps if you have to unite more than twice than it is not possible else possible and hence increase ans by 1 but the main caveat is handling leading zeroes

  • @UnknownLearner-od3qn
    @UnknownLearner-od3qn 2 месяца назад

    First viewer🥰, but sir quality is upto 360p only

    • @codingmohan
      @codingmohan  2 месяца назад +1

      It takes some time for RUclips to process video in higher formats. It should be all good now.