10 Largest number in K swaps Code and Time Complexity

Поделиться
HTML-код
  • Опубликовано: 18 сен 2024
  • Given a number K and string str of digits denoting a positive integer, build the largest number possible by performing swap operations on the digits of str at most K times.
    Example 1:
    Input:
    K = 4
    str = "1234567"
    Output:
    7654321
    Explanation:
    Three swaps can make the
    input 1234567 to 7654321, swapping 1
    with 7, 2 with 6 and finally 3 with 5
    ------------------------------------------------------------------------------------------
    Here are some of the gears that I use almost everyday:
    🖊️ : My Pen (Used in videos too): amzn.to/38fKSM1
    👨🏻‍💻 : My Apple Macbook pro: amzn.to/3w8iZh6
    💻 : My gaming laptop: amzn.to/3yjcn23
    📱 : My Ipad: amzn.to/39yEMGS
    ✏️ : My Apple Pencil: amzn.to/3kMnKYf
    🎧 : My Headphones: amzn.to/3kMOzM7
    💺 : My Chair: amzn.to/385weqR
    🛋 : My Table: amzn.to/3TyU2IU
    ⏰ : My Clock: amzn.to/3slFUV3
    🙋🏻‍♀️ : My girlfriend: amzn.to/3M6zLDK ¯\_(ツ)_/¯
    PS: While having good gears help you perform efficiently, don’t get under the impression that they will make you successful without any hard work.

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

  • @pratyushkumarsahoo6117
    @pratyushkumarsahoo6117 7 месяцев назад +30

    please make a playlist on trees and graphs

  • @keerthankumarc2681
    @keerthankumarc2681 29 дней назад +3

    correction the max element we need to find is
    char max = *max_element(str.begin()+start,str.end())🙃

  • @OIAOa
    @OIAOa 7 месяцев назад +3

    It's a humble request to bhaiya
    Please make playlist on trees,array and strings.....
    I found at your channel in sliding window playlist it was amazing by seeing the problem im able to solve...
    Thank you so much 👍❤
    Your teaching was perfect 😊

  • @rishabhahuja7413
    @rishabhahuja7413 7 месяцев назад +14

    Sir waiting for trees and graphs!! sb achi companies graph puch rhi hai

    • @subhadiphazra2602
      @subhadiphazra2602 7 месяцев назад +1

      Yes sir he is correct

    • @rishabhahuja7413
      @rishabhahuja7413 7 месяцев назад +3

      Not comparing with anyone, Aditya bhai ka andaz hi alg hai

  • @mohit6215
    @mohit6215 7 месяцев назад +27

    Vote for graphs playlist 👆 . Ab to hamara dard sunle 😢

  • @varunpalsingh3822
    @varunpalsingh3822 7 месяцев назад +7

    Tree and graphs plz ❤

  • @sambhavjain3653
    @sambhavjain3653 24 дня назад

    @TheAdityaVerma bhai you are awesome man!

  • @neelthakker7070
    @neelthakker7070 7 месяцев назад

    Thanks a lot for the DP playlist ❣️

  • @ManishKumar-ux5un
    @ManishKumar-ux5un 7 месяцев назад

    Thanks a lot for sharing your coding experience learning so well. I really appreciate your effort. Your way of tackling questions are awesome. Very nice!!.
    Please try to complete all backtracking questions as soon as possible (its a kind request to you).
    One more request: If possible please choose Tree and Graph also. (Tree first)

  • @cool7827
    @cool7827 7 месяцев назад +15

    There is virat in cricket
    And there is Aditya Verma sir for DSA👑

  • @Prateek_Mantry
    @Prateek_Mantry 4 месяца назад +1

    thank you.

  • @chandrachurmukherjeejucse5816
    @chandrachurmukherjeejucse5816 7 месяцев назад

    Great lecture.

  • @lostcyrus8578
    @lostcyrus8578 6 месяцев назад +1

    Please complete the remaining dp playlist variations of LIS , kadanes ,grid nd rest others . waiting for it so much long time

  • @yashassurendra5653
    @yashassurendra5653 7 месяцев назад

    Back in Business 😤🔥

  • @jswlprtk
    @jswlprtk 7 месяцев назад +4

    Finally!

  • @ajaygopireddy3188
    @ajaygopireddy3188 7 месяцев назад +1

    Sir, please add TC in the next videos as well

  • @lofireverbz-wy7go
    @lofireverbz-wy7go 7 месяцев назад +8

    month mai ek video daalre ho ,kuch to socho bhiaiya hmare baare mai

  • @mukeshrawat1304
    @mukeshrawat1304 7 месяцев назад +3

    Wo Basics of Backtracking wali video ke Outro mai "subscribe if you want girlfriend" tha, Subscribe toh kar diya, wo girlfriend bhi mil jati to acha rehta, graph ki playlist 4-5 saal delay bhi ho jaye to chalega 😶

  • @mohit6215
    @mohit6215 7 месяцев назад +2

    He will be with us ❤ only

  • @rishabsharma5307
    @rishabsharma5307 4 месяца назад

    amazing video

  • @nagendrabommireddi8437
    @nagendrabommireddi8437 7 месяцев назад

    thanks a lot

  • @rahularyan9808
    @rahularyan9808 7 месяцев назад +3

    Graph please

  • @akashpurbia4390
    @akashpurbia4390 7 месяцев назад +2

    🙌

  • @parvahuja7618
    @parvahuja7618 7 месяцев назад

    sir stack ki playlist please complete kar dijiye

  • @abhinjr4918
    @abhinjr4918 7 месяцев назад

    Who all think he was dead......
    I searched in google today is he dead than saw he uploaded latest video 2 months ago....
    This is the correct time he has arrived ...
    Lagtha hai bhagwaan ne ek farishtha beja hai, verma bhai muje appke sath kam karna hai.... I am coming flipkart next year placement hai.....

  • @suraj_patwa
    @suraj_patwa 7 месяцев назад +3

    Sir aak din live Instagram Or RUclips

  • @CrimeFilesJustice
    @CrimeFilesJustice 7 месяцев назад +2

    Graph and tree please

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

    C++ code:
    class Solution
    {
    public:
    void solve(string &str, int k, int start, string &ans){
    if(k==0 || start==str.size()-1){
    return;
    }
    char maxs= *max_element(str.begin()+start,str.end());
    for(int i=start+1;i

  • @diglive123
    @diglive123 6 месяцев назад

    Can we have the base condition as k==0 or all the numbers in the result string to be in decreasing order??
    I'm not able to intuitively understand the need for the start variable to go all the way to the end of the input string.
    Any help/comment on the same is greatly appreciated.
    Thanks in advance!!!

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

      Consider the example 7512, and let's say k=2. In this case we only need one swap, swap 1 and 2 and we get the largest number 7521, we did not even need 2 swaps, so in cases like these k will never reduce to zero and the recursion would never stop, that is why the other base condition is added.

  • @VickeyKumar-lk3vj
    @VickeyKumar-lk3vj 6 месяцев назад

    I think k swap using inplace insertion sort would be better for this

  • @harki-v8m
    @harki-v8m 7 месяцев назад

    how to make recursion strong i am facing issues in recursion

  • @mohit6215
    @mohit6215 7 месяцев назад +1

    Aditya verma sir live ajao ek baar ❤

  • @hritikaroy6797
    @hritikaroy6797 5 месяцев назад

    what will be the equivalent function for max_element() in JAVA? Can anyone help me?

    • @6ft2
      @6ft2 Месяц назад

      max()

    • @manasareddy8715
      @manasareddy8715 8 дней назад

      char maxs = str.substring(start).chars()
      .mapToObj(c -> (char) c)
      .max(Character::compareTo)
      .orElse(Character.MIN_VALUE);

  • @_desouvik
    @_desouvik 4 месяца назад +1

    Subscribed in the name of Bengali Girls

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

    Is it only me who feels that the volume is low?