Sort colors | Leetcode #75

Sdílet
Vložit
  • čas přidán 7. 09. 2024

Komentáře • 241

  • @r4riaz
    @r4riaz Před 4 lety +50

    Thank you, you explained it very well, quick n simple. Others are wasting time for around 20 min.

  • @pratik2319
    @pratik2319 Před 4 lety +89

    I think you have to use 'else if' instead of if everywhere. Because for this ex 2,0,2,1,1,0 the output will come as 001212
    Hope this will help you, or else if I am wrong , Please explain...Thank you

  • @zubairzafar480
    @zubairzafar480 Před rokem +1

    It was the best video on entire youtube. I love your simplest explanation.

  • @_overide
    @_overide Před 4 lety +18

    Very succinctly explained, I remember solving this problem in O(n) but solution was very messy, this is just clean and simple!. Thanks!

  • @shubhamhire9390
    @shubhamhire9390 Před 2 lety +4

    Amazing explanation in such a less time👍👌

  • @RajKumar-qv7ci
    @RajKumar-qv7ci Před 4 lety +7

    Nice explaination. We can solve this just counting number of 1's,2's and 0's .

    • @techdose4u
      @techdose4u  Před 4 lety

      Yes correct.

    • @ajaychinni3148
      @ajaychinni3148 Před 4 lety +1

      yes we can, but u will have to traverse the array two time once for counting next for replacing them

    • @Voice_Of_Thoughts
      @Voice_Of_Thoughts Před 4 lety

      @@ajaychinni3148 yah

    • @neghatnazir1668
      @neghatnazir1668 Před 4 lety

      @@ajaychinni3148 nope we can maintain three variables count0 count1 count 2 and treverse array whenever 0 occurs increment count0 similarly for count1 and count2 and thn print ....O(N)

    • @ssahoo1985
      @ssahoo1985 Před 4 lety

      Actually thought that will be still O(N) time but space will not be linear. That catch is it should be linear in space too.

  • @syno.nymous01
    @syno.nymous01 Před 4 měsíci

    The easiest explanation I came across.

  • @kshitijshirole2210
    @kshitijshirole2210 Před 3 lety +12

    One idea can be (though not optimal )...iterating through array & calculating occurrences of 0s 1s 2s in 3 variables and placing them (0 1 2 ) accordingly into original array...

    • @choudharyhimanshu4134
      @choudharyhimanshu4134 Před 2 lety

      I have done it like that only, but then I thought that it was not the optimal way and so I came here.

    • @suraj8092
      @suraj8092 Před 7 měsíci

      That's a bucket sort or count sort approach with 2 - pass solution.

  • @mananvarma5944
    @mananvarma5944 Před 3 lety +3

    Another (simpler) approach would be counting zeros and ones. Then mutating the array accordingly, it'll also take O(n) time & constant space.

    • @techdose4u
      @techdose4u  Před 3 lety +1

      Yes right.

    • @mananvarma5944
      @mananvarma5944 Před 3 lety +5

      @@techdose4u But in a face to face round the interviewer might ask to optimize it further in a single pass as this solution takes 2 passes. In that case this Dutch Flag algorithm is the way to go.

  • @adityaanand4749
    @adityaanand4749 Před 8 měsíci +1

    Nice straight forward explanation.

  • @kunalkheeva
    @kunalkheeva Před rokem +1

    simple and precise! thank you.

  • @dineshrajendran7128
    @dineshrajendran7128 Před 2 lety +3

    Thanks! Your solutions are really well explained and simple to understand.

  • @gigachad6844
    @gigachad6844 Před 2 lety +1

    Count Sort will also do this in O(3N) ie. Linear time O(N) but it's mentioned to do it in one-pass and 3N is actually 3 pass

  • @sambeetnayak1002
    @sambeetnayak1002 Před 3 lety +1

    At a time only one condition should be executed, so need to use else if / switch cases.
    Btw explanation was good.

  • @sanskrutikapade4238
    @sanskrutikapade4238 Před 2 lety

    very good, helped me a day before my interview. thanks :)

  • @dmsohel1335
    @dmsohel1335 Před 4 lety +1

    this is better with no confusion
    Keep three counter c0 to count 0s, c1 to count 1s and c2 to count 2s
    Traverse through the array and increase the count of c0 is the element is 0,increase the count of c1 is the element is 1 and increase the count of c2 is the element is 2
    Now again traverse the array and replace first c0 elements with 0, next c1 elements with 1 and next c2 elements with 2.

  • @jianingzhuang104
    @jianingzhuang104 Před 4 lety +2

    Great video! Concise and clear!

  • @arkadeepsen6731
    @arkadeepsen6731 Před 3 lety +1

    You teach really good, I guess it should be else if instead of the if in the latter two conditions.

  • @user-oy4kf5wr8l
    @user-oy4kf5wr8l Před 3 lety +1

    Thank you buddy! u made it very clear ! we love u !

    • @techdose4u
      @techdose4u  Před 3 lety

      Welcome ❤️

    • @user-oy4kf5wr8l
      @user-oy4kf5wr8l Před 3 lety +1

      ​@@techdose4u A question plz Tech dose. There r so many algo, i really don't know how is it possible for me to remember all of these, for example, this video. why m++ when arr[m] == 0 and 1... and also for other questions.....
      could u plz give me a little suggestion plz? super struggling here....ToT

    • @techdose4u
      @techdose4u  Před 3 lety

      This is not really an algo but just a hack :P You can do using counting the element frequencies :) You will get these ideas once have a lot of practice under your belt 😁 Ping me for any guidance on LinkedIn or Whatsapp or Instagram.

    • @user-oy4kf5wr8l
      @user-oy4kf5wr8l Před 3 lety +1

      @@techdose4u Whatsapp number plz !!! thank you ToT

    • @techdose4u
      @techdose4u  Před 3 lety

      @@user-oy4kf5wr8l +91 8918633037

  • @666Imaginative
    @666Imaginative Před 2 lety

    you give the best explanation FR

  • @DonTaldo
    @DonTaldo Před 3 lety +8

    Nice explanation!
    Just a quick note, I think the code should be
    if( ... )
    else if ( ... )
    else if ( ... )
    instead the
    if (...)
    if (...)
    if (...).
    I'm doing the "Sort Colors" problem from leetcode and I needed to change that

    • @iaashu98x
      @iaashu98x Před 2 lety

      if you want to decrease the runtime, don't put 'else if(a[m]==1)' instead put this case in 'else block'. I guess, he was trying to keep the runtime low that why he put only if block but that was incorrect.

  • @poojaupadhyay6364
    @poojaupadhyay6364 Před 4 lety +4

    this code does not run for multiple test cases on geeksforgeeks platform.

    • @techdose4u
      @techdose4u  Před 4 lety

      Maybe the constraints are changed or else try to tweak the code a little in if else statements.

  • @jaydeepmahajan6598
    @jaydeepmahajan6598 Před 4 lety +5

    Hey , but you need to explain , how this idea comes into your mind , like how you analyse the problem and find this approach ?

    • @techdose4u
      @techdose4u  Před 4 lety +2

      My explanation style was slightly different earlier but later I focussed more on intuition. So maybe you might different kind of approaches to my explanation from an old video compared to the ones I explained in past 4 months. But still I hope you can understand why we took the approach 😅 I evolved my style over time.

    • @babbarutkarsh7770
      @babbarutkarsh7770 Před 4 lety +2

      @@techdose4u yes this video does'nt seems like TECH DOSE's its more of a gfg kind. We now expect more than just to explain code.

    • @Shailswap14
      @Shailswap14 Před 4 lety

      It is a typical Dutch National Flag Algo problem

    • @sehejwahla5437
      @sehejwahla5437 Před 3 lety

      @@babbarutkarsh7770 Bhai mat dekh fir. He is helping us for free and u have the guts to point out his mistakes !! Don't be a choosing beggar

    • @varsha9094
      @varsha9094 Před 3 lety +1

      @@sehejwahla5437 have you ever heard of 'constructive criticism' ? He is pointing out mistake to improve quality right!!!...

  • @lalitkumarnaidu1
    @lalitkumarnaidu1 Před 4 lety +2

    Thanks for the video, there are some cases which won't work as the terminating conditions are incorrect. Within the loop, we are incrementing pointers which may go out of bounds or may lead to inconsistent results (as Pratik24 mentioned), below will work.
    while(m

    • @alstrarame3387
      @alstrarame3387 Před 4 lety

      It would be also be Okay if we add else if insted if's

  • @myriad1703
    @myriad1703 Před rokem

    Thanks for the explanation buddy

  • @nithinkumar9226
    @nithinkumar9226 Před 3 lety +1

    Nice explanation sir
    Tq ❤

  • @shadanzahid4594
    @shadanzahid4594 Před 4 lety +7

    I think we don't need to swap if we are getting 1 because if we fix two element i.e 0 and 2 then 1 will be automatically fixed in between , so we can reduce work

  • @philosphize
    @philosphize Před rokem

    Thanks for sharing

  • @ankitupadhyay918
    @ankitupadhyay918 Před 3 lety +1

    Op explanation 🤯🤯🤯🤯😀

  • @Voice_Of_Thoughts
    @Voice_Of_Thoughts Před 4 lety

    class Solution
    {
    public void sortColors(int[] nums)
    {
    int i,j,k;
    int len=nums.length;
    i=0;
    j=0;
    k=len-1;

    while(j

  • @premhulikoppe1470
    @premhulikoppe1470 Před 2 lety

    short and effective one

  • @nishantsharma3100
    @nishantsharma3100 Před 4 lety +1

    nice and fast explanation . liked it bhai.

  • @pryansh_
    @pryansh_ Před 3 lety +2

    So well explained 😄😄

  • @sagarbora7768
    @sagarbora7768 Před 3 lety +1

    Thanks found your explanation intutive !

  • @VipinChaudhary14119
    @VipinChaudhary14119 Před 4 lety +1

    Very nicely explained . good job

  • @akankshakanjolia2969
    @akankshakanjolia2969 Před 3 lety +2

    Awesome explanation

  • @patilsoham
    @patilsoham Před 4 lety +1

    Nice explanation...It helped alot.
    Thank you

  • @karanhemdev5325
    @karanhemdev5325 Před 5 lety +3

    if you want a solution with complexity O(n) then you can also do like this...
    1st find all 2's and put it in stack then
    find all 1's and put it in stack then
    find all 0's and put it in stack then pop all elements... your output is sorted...
    here we got (3n) traversal hence equivalent to O(n)...
    yeah but yours O(n) is better than mine O(n)

    • @techdose4u
      @techdose4u  Před 5 lety +2

      Yes... And also your technique is taking O(3n) extra space. But the technique in video is for O(1) space.

    • @sivaganesh4489
      @sivaganesh4489 Před 4 lety

      Another apporach is simply count 0's 1's and print it. For 2's len-0's-1's but the solution in video was algorithmic

  • @Margdarshak_1
    @Margdarshak_1 Před 3 lety +1

    We can also use hashing

  • @vishalmane5353
    @vishalmane5353 Před 3 lety +1

    there are some changes in the solution
    correct solution :
    if(a[m] ==2)
    --h;
    in video :
    if(a[m] ==2)
    h--;

  • @chetanshrivastava3762
    @chetanshrivastava3762 Před 4 lety +1

    Very Nice explanation sir..

  • @sehejwahla5437
    @sehejwahla5437 Před 3 lety +1

    Thanks bro !! Ur punjabi fan

  • @saruncse85
    @saruncse85 Před 3 lety +1

    Nice Explanation.

  • @shivanshkaushal420
    @shivanshkaushal420 Před 3 lety +1

    sir why in third step we havnot did m++ also? . is it because after swapping arr[h] with arr[m]... the current arr[m] can be 0 or 1 ... if its 1 we'll move forward else if its 0 we'll have to swap it with arr[l]; ??

  • @mwshubham
    @mwshubham Před 3 lety +1

    Leetcode 75 Sort colors

  • @ZalTech
    @ZalTech Před 4 lety +2

    If we knows that their is only 0,1,2 element. then why not just count frq. Of those 3 and fill the array it's also takes O(n) time and O(1) space.

    • @techdose4u
      @techdose4u  Před 4 lety +1

      But that will take 2 pass of array. You might be required to solve this in one pass. Like it's required on leetcode.

    • @Dizzydizzydizzy7
      @Dizzydizzydizzy7 Před 3 lety +1

      @@techdose4u thank you so so much!! This is really a smart solution!

  • @saisriangajala8399
    @saisriangajala8399 Před 3 lety

    I thought of this solution but missed m

  • @pabloarkadiusz4687
    @pabloarkadiusz4687 Před 3 lety +2

    This can be solved also with counting sort. And it can also be done in place just using 3 variables instead of array as usually

    • @zah1d_ali
      @zah1d_ali Před 3 lety

      but than time complexity will be o(n) + o(n) = 2o(n)
      but using this algo time complexity is just o(n)

    • @AdrianGonzalezBlogs
      @AdrianGonzalezBlogs Před 3 lety

      @@zah1d_ali O(2n) is still the same as O(n), anyways, both are good solutions

  • @amankumarjha9438
    @amankumarjha9438 Před 3 lety

    Very nice explanation sir.

  • @hemanthar8363
    @hemanthar8363 Před 3 lety

    Nicely explained brother!!

  • @chanpreetsingh007
    @chanpreetsingh007 Před 3 lety +1

    Just keep count of number of 0,1 and 2...and fill the array with 0 ,1 and 2 Respectively

  • @gsujithkumar1417
    @gsujithkumar1417 Před 3 lety +1

    Maintaining count of 0,1,2's and putting that many back in the array is far simpler

  • @harifrahman8054
    @harifrahman8054 Před 4 lety +1

    Nice solution :) keep going

  • @sangramkapre
    @sangramkapre Před 4 lety +1

    Why not simply count 0s, 1s and 2s and then fill the array accordingly? I guess it will take two passes as opposed to one so the solution mentioned in the video is more efficient (though might not be scalable when instead of 2s, we have a higher max limit).

    • @techdose4u
      @techdose4u  Před 4 lety +1

      Yea, but making use of the constraints is a good thing :)

  • @paragroy5359
    @paragroy5359 Před 3 lety +1

    Nice explanation sir.......

  • @bhanupratapsingh8982
    @bhanupratapsingh8982 Před 4 lety +1

    very well explained😁

  • @MMNayem-dq4kd
    @MMNayem-dq4kd Před rokem

    Thanks

  • @nandhagopalcs5608
    @nandhagopalcs5608 Před 3 lety +1

    Really helpful

  • @TheArbaaz-rn2tq
    @TheArbaaz-rn2tq Před 4 lety +1

    What is the difference if we write len(nums) or len(nums)-1? In 2nd it indicates starting index is 0 then what about len(nums) ?

    • @techdose4u
      @techdose4u  Před 4 lety +2

      If you wanna access array index then we use len(nums)-1. If you do len(nums) then you need to explicitly subtract. Anyone is good and works fine :)

  • @AnkitMishra-mz4xt
    @AnkitMishra-mz4xt Před 4 lety +1

    USE ELSE IF , other wise the output will be wrong , for such like cases 2 2 1 1 2 1 0 0 1 2 2

  • @ankitraj4179
    @ankitraj4179 Před 2 měsíci

    Java Code (Beats 100 %)
    class Solution {
    public void sortColors(int[] nums) {
    int n = nums.length ;
    int[] arr = new int[3] ;
    int element = 0 ;
    for(int i = 0 ; i < n ; i++){
    element = nums[i] ;
    arr[element]++ ;
    }
    int count = 0 ;
    int k = 0 ;
    for(int i = 0 ; i 0){
    nums[k] = i ;
    k++ ;
    count-- ;
    }
    }
    }
    }

  • @theofficialgauravsharma8731

    Awesome!

  • @YashM1234
    @YashM1234 Před 2 lety +1

    why don’t we just count 0s ,1s and 2s.. Generate new arr and return
    O(2N)

    • @techdose4u
      @techdose4u  Před 2 lety +1

      Doing it inplace and one traversal :)

  • @nknidhi321
    @nknidhi321 Před 3 lety +1

    Awesome ❤️

  • @neerajmahapatra5239
    @neerajmahapatra5239 Před 3 lety

    Understood.

  • @rakeshjaiswal2790
    @rakeshjaiswal2790 Před 2 lety

    This will not pass all the test cases - for eg. 1,0,1,2,2,1. as you are just incrementing when its 1, the resulting array will not be correctly sorted.

  • @ShreyaSingh-vr9qi
    @ShreyaSingh-vr9qi Před 4 lety +1

    Awesome explaination, hey you have done a lot of good interview preparation videos. Its a reuqest can u make a repository type something where you can put your videos topicwise ( Graph, Tree,...) . It will help during preparing on a topic to check all imoprtant problems on that topic..

    • @techdose4u
      @techdose4u  Před 4 lety +3

      I am currently working on my own website. It will be up in around a couple of months. You can find everything well organized there :)

    • @karann6010
      @karann6010 Před 4 lety

      @@techdose4u waiting

    • @ritishdhiman26
      @ritishdhiman26 Před 4 lety

      @@techdose4u
      You are doing really an amazing work :)
      Thanks a lot.

    • @moulikasunesh2834
      @moulikasunesh2834 Před 4 lety +1

      @@techdose4u is the website ready? would love to take a look

    • @techdose4u
      @techdose4u  Před 4 lety +1

      @@moulikasunesh2834 it's ready. Currently organizing the content.

  • @shubhamsonal5871
    @shubhamsonal5871 Před 5 lety +1

    Awesome

  • @hassaanistic
    @hassaanistic Před rokem

    love youuu broo

  • @hari8568
    @hari8568 Před 4 lety +2

    Much easier solution-Make a count array with elements (0,0,0) where 0th index is 0 count 1st index is 1st count 2nd index 2nd count.Traverse the given array in question once and keep updating the 0 array then rewrite the question array with appropriate counts of 0,1,2

    • @techdose4u
      @techdose4u  Před 4 lety +9

      This is using 2 traversals. You could have done in 1 traversal by following the swapping method.

    • @llawliet1750
      @llawliet1750 Před rokem

      the interviewer will kick you out of the interview if you say this

    • @hari8568
      @hari8568 Před rokem

      @@llawliet1750 it's a solution not the best but ok ,O(2n) approximates to O(n)

  • @shubhamsingh4701
    @shubhamsingh4701 Před 2 lety

    instead of a[m]==2 is should be else{} other wise some case will fail for 2 2 1 1 2 1 0 0 1 2 2 and many more

  • @CodeSuccessChronicle
    @CodeSuccessChronicle Před 3 lety +1

    perfect 👌

  • @NarendraKumar-by6vv
    @NarendraKumar-by6vv Před 7 měsíci

    ALL THREE if statement doesn't work beacause 3 if condition can be true simultaneously.

  • @harshpatel1385
    @harshpatel1385 Před 5 lety +1

    nice explanation

  • @aksharkashyap5872
    @aksharkashyap5872 Před 4 lety +2

    //those who are getting any problem with the mentioned code on video can run this code:
    int left = 0, right = a.length -1;
    for(int i=0;i

  • @ssahoo1985
    @ssahoo1985 Před 4 lety +1

    This solution will not work if we do not have 1 in the list, because m will never increased.

  • @yashnarang637
    @yashnarang637 Před 3 lety

    i have a same solution with same approach but a test case of size 65754 gives an error in gfg idk why and the solution is working fine for the element of small array

    • @rosonerri-faithful
      @rosonerri-faithful Před 3 lety

      yes bro, mine too. i dont understand whats the problem since it is returning 00000000000000.......like gfgs output

    • @yashnarang637
      @yashnarang637 Před 3 lety

      Can anyone answer our question

  • @SomnathDas-fg2qc
    @SomnathDas-fg2qc Před 4 lety +1

    sir can we use this technique whenever we required sorting in a problem,suppose there list of no in aaray,we have to sort it,then by using direct sorting can we use this process

    • @techdose4u
      @techdose4u  Před 4 lety +2

      No you cannot. This is a very specific technique. Just see the problem and try to think of algo accordingly. Don't take any technique for granted to always work.

  • @643kanavguleria9
    @643kanavguleria9 Před 3 lety +2

    i think in while condition
    the condition should be
    while(mid while(mid

  • @aznstride4325
    @aznstride4325 Před 2 lety

    Counting sort can also solve this in O(n) since range of nums[i] is constant :)

    • @shubhamraj25
      @shubhamraj25 Před rokem

      yeah but that will take two passes and this algo does it only in single pass :)

  • @nilaysheth3283
    @nilaysheth3283 Před 3 lety

    Can we achieve the solution using low = 0 , mid = n-1 and high = n -1 ?

  • @tauros5651
    @tauros5651 Před 3 lety

    Thanks a lot

  • @AruneshSrivastava
    @AruneshSrivastava Před 4 lety +1

    nice explanation .. but it's not in-place .. the ordering of 2's are changed ... does anybody know any in-place way of doing it .

    • @techdose4u
      @techdose4u  Před 4 lety +4

      Inplace means you don't use any extra space but manipulate the words or elements within its own space. I think you are confusing with something else. Read this: en.m.wikipedia.org/wiki/In-place_algorithm

    • @AruneshSrivastava
      @AruneshSrivastava Před 4 lety

      yeah , you are right .. what i wanted to say ..that it's not stable .. i mean the ordering differs from the original array .

    • @BarkaDog
      @BarkaDog Před 4 lety +1

      @@AruneshSrivastava of course the ordering will change you are sorting it lol

  • @rahuldey5564
    @rahuldey5564 Před 2 měsíci

    what is this algorithm called?

  • @ravishankarsingh7512
    @ravishankarsingh7512 Před 4 lety +1

    Why you didn't run the code in java...and where I can get code

    • @techdose4u
      @techdose4u  Před 4 lety +1

      I can only do one language. The main focus is to explain the logic. You can get code on internet or geeksforgeeks. See comments as well.

  • @ManojKumar-hj7fh
    @ManojKumar-hj7fh Před 4 lety +1

    How do you come up with approaches, is it because of practice ?

  • @hirakmondal6174
    @hirakmondal6174 Před 3 lety +1

    Why not simply count the number of 0's 1's and 2's and then fill the array?

  • @marriagedance8657
    @marriagedance8657 Před 4 lety +9

    U should have explained the intuition. Instead, You just dry run the solution. Not much beneficial.

    • @techdose4u
      @techdose4u  Před 4 lety +6

      The intuition is already clear from the dry run. Since you have just 3 different values, so you can sort them like a Dutch flag. The intuition was already clear i guess. Now the tricky thing was to sort in just O(N) instead of O(NlogN). So we used the 3 pointer technique which segregates those values. I hope it's clear now :)

  • @user-fq1bk8co5r
    @user-fq1bk8co5r Před rokem

    not working for 2,0,1

  • @utkarshgupta2909
    @utkarshgupta2909 Před 3 lety +1

    Why not just count the 0s 1 2s and place them in array?

    • @techdose4u
      @techdose4u  Před 3 lety +1

      You can do that too in 2 traversals.

    • @utkarshgupta2909
      @utkarshgupta2909 Před 3 lety +1

      @@techdose4u yeah.. so this approach was more related to 1 traversal.. got it..

    • @techdose4u
      @techdose4u  Před 3 lety +1

      @@utkarshgupta2909 yea. Just for interview sake 😅

  • @neghatnazir1668
    @neghatnazir1668 Před 4 lety +1

    it can b solved using multiset in logn time

    • @techdose4u
      @techdose4u  Před 4 lety +1

      How? I don't think you can solve below O(N).

    • @neghatnazir1668
      @neghatnazir1668 Před 4 lety

      @@techdose4u i solved this
      int n;
      cin>>n;
      int a[n];
      multiset s;
      for(int i=0;i>a[i];
      s.insert(a[i]);
      }
      for(auto it=s.begin();it!=s.end();it++)
      {
      cout

    • @killadasatyaaditya5960
      @killadasatyaaditya5960 Před 4 lety

      @@neghatnazir1668 The question is to sort, not to print the sort form of given array. You have to modify the array

  • @rishurana9655
    @rishurana9655 Před 3 lety

    what is the intuition behind this?

  • @AnasMourad
    @AnasMourad Před 3 lety

    What software do you use?

  • @shaswatsingh
    @shaswatsingh Před 4 lety

    WHICH SOFTWARE DID YOU USE

  • @vikasrai4915
    @vikasrai4915 Před 4 lety

    how can we modify it if we want a stable sort?

    • @techdose4u
      @techdose4u  Před 4 lety

      To maintain order, one simple way is to copy and perform operation on a different array which will take O(N) time and I know you might have thought of this.

    • @vikasrai4915
      @vikasrai4915 Před 4 lety +1

      please clarify your approach.
      One approach may be to avoid swapping if both the elements are same and update indexes accordingly.

  • @ahmedatef4171
    @ahmedatef4171 Před 3 lety

    send this code please

  • @AnkitSingh-zj2uc
    @AnkitSingh-zj2uc Před 4 lety +1

    Dutch algorithm

  • @techconvos
    @techconvos Před 4 lety +1

    this explaination coould be more better and clear, next time while making video ensure that you will work on that

  • @spetsnaz_2
    @spetsnaz_2 Před 5 lety +1

    Can we name this method as Indian Flag Method??

  • @mathan3192
    @mathan3192 Před 4 lety

    two line using Java lib function , but not O(n) :|
    Arrays.sort(arr);
    System.out.println(Arrays.toString(arr).replaceAll("\\]","").replaceAll(",","").
    replaceAll("\\[",""));