Minimum swap required to Sort an Array

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

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

  • @avtarchandra2407
    @avtarchandra2407 2 года назад +3

    rupesh sir gazab ka logic hai and your skill of teaching is awesome ,,,keep teaching

    • @CppNuts
      @CppNuts  2 года назад

      Thanks dude..

  • @samuelluswata
    @samuelluswata 9 месяцев назад

    Best explanation on this thus far

  • @ManishSharma-ys5ws
    @ManishSharma-ys5ws 2 года назад +1

    What will be the Time Complexity of this code especially that swapping part... I think it may go upto (n^2)

    • @kshitijgupta592
      @kshitijgupta592 2 года назад

      O(n)

    • @JEMohammadAtif
      @JEMohammadAtif Год назад

      O(2n) in worst case@@kshitijgupta592

    • @koeber99
      @koeber99 Год назад

      @@kshitijgupta592 Sorting is O(n*Log(n)), So this code is Time complexity is O(n)+n*Log(n) +O(n).

  • @ChandraShekhar-by3cd
    @ChandraShekhar-by3cd 2 года назад

    Thanks a lot for such an informative video. Please keep uplaodng more video on leetcode.

    • @CppNuts
      @CppNuts  2 года назад +1

      Sure I will

  • @badassopenpolling
    @badassopenpolling 2 года назад +3

    What kind of solution this is. !!!!
    To get minimum swap in sort : you sorted the array first and then found out the location and comparing.
    This is a hack , not a solution.

    • @CppNuts
      @CppNuts  2 года назад +1

      Actually your function should return the correct output no matter what you do inside that function :D

    • @badassopenpolling
      @badassopenpolling 2 года назад

      @@CppNuts hahahaahhahahaah anyways I read your rest of the contents and they are good.

    • @CppNuts
      @CppNuts  2 года назад

      Thanks..

    • @aby_yadav
      @aby_yadav Год назад

      Rupesh could have used std::map instead of vector, then he didn't need to swap.

  • @bl7327
    @bl7327 2 года назад

    can we do no of swaps = no. of misplaced pairs/2 ??

  • @ankitahlawat4812
    @ankitahlawat4812 2 года назад

    Nice explanation

    • @CppNuts
      @CppNuts  2 года назад

      I saw you after long time, it makes me feel that i am still relevant.. :D

    • @ankitahlawat4812
      @ankitahlawat4812 2 года назад

      @@CppNuts I added your videos in watch later list due to ofc work🙁🙁....I ll watch all of them ...
      No doubt ..your videos always nice and wonderful.

    • @CppNuts
      @CppNuts  2 года назад

      @@ankitahlawat4812 Felt good.. thanks..

    • @bingumallarahul3922
      @bingumallarahul3922 2 года назад

      @@CppNuts yes your videos are good, do videod for greedy, dynamic programming,divide and conquer also

  • @memeswallah5253
    @memeswallah5253 3 месяца назад

    amazing

  • @pradeexsu
    @pradeexsu 2 года назад +1

    nice and simple, 👍 thank you