hatiger
BAN USERpublic static int KthMaxSortedMartix(int k, int n, int[,] dataArray)
{
int res = -1;
int[] maxIndexex = new int[k];
for (int i = 0; i < k; ++i)
{
maxIndexex[i] = n - 1;
}
for (int i = 0; i < k; ++i)
{
int max = int.MinValue;
int maxIndex = 0;
for (int j = 0; j < k; ++j)
{
if(dataArray[n-j-1, maxIndexex[j]] > max)
{
maxIndex = j;
max = dataArray[n-j-1, maxIndexex[j]];
}
}
maxIndexex[maxIndex]--;
res = max;
}
return res;
}
A shot in the dark :)
A={x1, x2, x3, .. xn}
B={y1, y2, y3, .. yn}
Sum(A) = x1+x2+x3+...+xn (for all x)
Mul(A) = x1*x2*x3*...*xn (for all x!=0)
Sum(B) = y1+y2+y3+...+yn (for all y)
Mul(B) = y1*y2*y3*...*yn (for all y!=0)
if(Sum(A) == Sum(B) && Mul(A) == Mul(B)
&& zerosCountIn(A) == zerosCountIn(B))
{
return true;
}
else
{
return false;
}
- hatiger July 28, 2014