Mauritus national flag problem

前端 未结 6 766
时光说笑
时光说笑 2021-02-14 16:52

I\'ve made a solution for the Dutch national flag problem already.

But this time, I want to try something more difficult: the Mauritus national flag problem - 4 colours,

6条回答
  •  礼貌的吻别
    2021-02-14 17:26

    function sort3(a:string[]):void{
        let low = 0;
        let mid1 = 0;
        let mid2 = 0;
        let high = a.length - 1;
        while(mid2<=high){
            switch(a[mid2]){
                case '0': [a[mid2],a[low]] = [a[low],a[mid2]];
                        low++;
                        if(mid1

提交回复
热议问题