Remove duplicate element pairs from multidimensional array

前端 未结 7 883
广开言路
广开言路 2020-12-11 07:23

I have an array that looks like this:

1.  coordinates = [ [16.343345, 35.123523],
2.                  [14.325423, 34.632723],
3.                  [15.231512,         


        
7条回答
  •  一向
    一向 (楼主)
    2020-12-11 07:49

    I am not sure about coordinates[][] dataType. Make the comparison accordingly.

      var dubJRows= new Array();
      for(int i = 0; i <  coordinates.length -2; i++){
        for(int j = i+1; j <  coordinates.length -1; j++){
            if (i != j && chk_dubJRows_not_contains(j)) {
               innerArray1 [1][1] = coordinates[i];
               innerArray2 [1][1] = coordinates[j];
               if ( innerArray1 [1][0] == innerArray2[1][0] 
                       && innerArray1[1][1] == innerArray2[1][1]) {
                   dubJRows.push(j);
                }
             }
           }
        }
        //REMOVE ALL dubJRows from coordinates.
    

提交回复
热议问题