I looked through SO careers and came across a job in which there was a pdf file with a couple of puzzles that wanted applicants to come.
Although I am not interested in working, I still read the questions and played in Visual Studio / SMSS. The first question was quite easy to solve, although I could not think how to optimize it (I decided it in C #). The second puzzle brings up only one obvious solution, and I cannot think of others.
I’m not sure that it’s bad to discuss these issues here, but if someone can give me some hints or perhaps suggest somewhere where I can ask about it without creating any grief, this will be appreciated.
Questions here: http://www.debtx.com/doc/DebtX_Programming_Problems.pdf
I could allow the first slide, but the second leads me to other ways of solving it than the obvious. Shame there is no PM function on SO ...
Solution for the boiler for the first part of C #:
public static bool Compare(int[] num, int[] div)
{
for (int i = 0; i < num.Length; i++)
{
for (int j = 0; j < div.Length; j++)
{
if (num[i] % div[j] == 0)
return true;
}
}
return false;
}
My SQL solutions
select Table1.Key1, Table1.Key2 from Table1 inner join Table2 on Table1.Key1 = Table2.key2 where IsDeleted=0
select * from Table1 where key1 in(select Key2 from Table2 where IsDeleted=0)
It all seems the same though
source
share