I have a small problem in finding the most efficient solution. I have a number, for example 10, of student ids. And some of those ids are relative(siblings) to each other. For those who are siblings leave only one of them for identifing, and doesn't matter which, first one is fine.
For example, the student ids
original
1, 2, 3, 4, 5, 6, 7, 8, 9, 10
where 1, 2, 3
are one family siblings, and 8, 9
are another. At the end I should have:
expected
1, 4, 5, 6, 7, 8, 10
I am doing it through loop.
UPDATE:
I just stopped to implement it, because it gets bigger and bigger. This is a big picture of what I have in my mind. I just gathered all sibling ids for each given id row by row, and then I was going to iterate per each. But like I said it's wasting time.
Code (in conceptual)
static string Trimsiblings(string ppl) { string[] pids=ppl.Split(','); Stack<string> personid=new Stack<string>(); foreach(string pid in pids) { // access database and check for all sibling // is for each individual pid // such as in example above // row 1: field 1=1, field2=2, field3=3 // row 2: field 1=8, field2=9 query = Select..where ..id = pid; // this line is pesudo code for(int i=0; i<query.Length; i++) { foreach(string pid in pids) { if(query.field1==pid) { personid.Push(pid);
} } } } }