Suggesting some missing test cases


  • 0

    initially, when i was constructing the right array; i did not add the "equals" sign just ">"
    still passed with wrong answer for example
    [1,2,1,2,2,2,2,2]
    2
    should be 0, 3, 5
    but with 0, 3, 6 still passed which is incorrect;
    since the questions asked for lexicographically smallest one.

    for(int i = w.length - 1; i >= 0; i--){
       //這邊來測,j 先從最低開始如果今天碰到 i >= j
       //那我們一定會更新 j = i; 因此 最大的一定在最左邊
       if(w[i] >= w[j]){
            j = i;    
       }
       right[i] = j;
    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.