We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
int max = 0;
List<int> matched = new List<int>();
for (int i = 0; i < n; i++)
{
int[] arr = Array.ConvertAll(topic[i].ToArray(), c => (int)Char.GetNumericValue(c));
for (int j = i + 1; j < n; j++)
{
int[] arr2 = Array.ConvertAll(topic[j].ToArray(), c => (int)Char.GetNumericValue(c));
int match = 0;
for (int k = 0; k < arr.Length; k++)
{
if((arr[k] | arr2[k]) == 1)
{
match++;
}
}
if(match > max)
{
max = match;
}
matched.Add(match);
}
}
int max_ = matched.Max();
int cnt = matched.Where(x => x.Equals(max)).Count();
Console.WriteLine(max);
Console.WriteLine(cnt);
You can optimize for sure.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
ACM ICPC Team
You are viewing a single comment's thread. Return to all comments →
for (int topic_i = 0; topic_i < n; topic_i++) { topic[topic_i] = Console.ReadLine(); }