1
I have a matrix A and B:
Method:
public static int[] RetornaDiferenca(int[] a, int[] b)
{...
}
Calling the method:
RetornaDiferença(new int[] {1, 2, 2}, new int[] {2})
The result would have to be: new int[] {1}
as all items of 'b' must be removed from 'a'
How To Do It Without?
[Edited] Another detail:
RetornaDiferença(new int[] {1, 2, 2}, new int[] {1})
The return has to be:
int[] {2,2}
Is there something you’ve tried? Why can’t you use LINQ? This description looks a lot like course/college exercise.
– Gabriel Heming
Linq makes it much easier, so I ask how to do it without using it. Ah, it’s nothing college - just practicing it yourself.
– Peres
It’s probably just exercise restriction, but I don’t think it’s too wide. Anyway: https://dotnetfiddle.net/KSL1pU I remembered the college days
– Rovann Linhalis
you need 2 loop , 1 to traverse B and for each item of B to traverse A and remove identical elements of B in A. and return A simple like this.
– Marco Souza
and
RetornaDiferença(new int[] {1, 2, 2}, new int[] {2,3})
what would be the return ?– Rovann Linhalis
It would be: new[] {1};
– Peres