Hello,
Can someone tell me the logic for removing duplicates from 2D array?
thanks
Printable View
Hello,
Can someone tell me the logic for removing duplicates from 2D array?
thanks
A few questions.
What happens when a duplicate is removed? Which way to you want to slide the remaining elements? By row or by column?
For example given this 2x2
12
24
to
14
2
or
12
4
Can you give an example of an array with duplicates and what you want the resultant array to look like?
I want to use hashset to remove duplicates becoz lines of code is less. I have a 2D array with all the duplicates. Now, I want to remove the duplicates and store the remaining elements into array. Here is the example, and my final array should be 1456,1457,1458,1459 in an array.
0 1
0 1458 1457
1 1457 1459
2 1456 1458
Can you edit your example and show the before and after arrays?
This looks like a one dim array?Quote:
my final array should be 1456,1457,1458,1459 in an array.
Here is the example according to array index. My final output should be 1458,1459,1456,1457 in 1D array.
0 1
0 1458 1457
1 1457 1459
2 1456 1458
You want to create a one dimensional array from the contents of the two dim array. Is that correct?
Your output array doesn't have the 0, 1 and 2 in it. Why were these removed?
Perhaps it'd be less ambiguous if you coded it like an array definition:
{ {123, 1233}, {333, 444}, {234, 444}}