I have 2D array where y is sorted and unique.so insert operation should be based on y.
x | y |
0.012 | 396.470 |
0.017 | 401.480 |
0.028 | 406.490 |
0.032 | 411.500 |
0.038 | 416.510 |
0.043 | 421.520 |
0.046 | 426.530 |
0.051 | 431.540 |
0.050 | 436.540 |
0.050 | 441.550 |
and now i have another inputed2darray
0.030 | 408.505 |
0.043 | 421.520 |
0.050 | 430.050 |
0.047 | 438.540 |
then output array should be like this
x | y |
0.012 | 396.470 |
0.017 | 410.480 |
0.028 | 406.490 |
0.030 | 408.505 |
0.032 | 411.500 |
0.038 | 416.510 |
0.043 | 421.520 |
0.046 | 426.530 |
0.050 | 430.050 |
0.051 | 431.540 |
0.050 | 436.540 |
0.047 | 438.540 |
0.050 | 441.550 |
and also return the index of inserted and non inserted(if the element is present in the list then not insert) element
outputindexarr=[3,6,8,11]
yellow highlighted:was not present in the given 2d array so it was inserted in the outputarray
green highlighted: was present in the given 2d array so it was inserted in the outputarray.