Skip to content

Instantly share code, notes, and snippets.

@gegagome
Created August 7, 2018 07:31
Show Gist options
  • Save gegagome/b0f65e08d7529d3963b0d98851781821 to your computer and use it in GitHub Desktop.
Save gegagome/b0f65e08d7529d3963b0d98851781821 to your computer and use it in GitHub Desktop.
static int[] usernameDisparity(string[] inputs)
{
// store results
int[] result = new int[inputs.Length];
// store results for array
List<int> resultInt = new List<int>();
for (int i = 0; i < inputs.Length; i++)
{
int total = 0;
for (int j = 0; j < inputs[i].Length; j++)
{
int count = 0;
string substring = inputs[i].Substring(j);
for (int k = 0; k < substring.Length; k++)
{
char a = inputs[i][k];
char b = substring[k];
if (a == b)
{
}
if (a != b)
{
break;
}
count++;
}
total = total + count;
}
resultInt.Add(total);
}
for (int i = 0; i < resultInt.Count; i++)
{
result[i] = resultInt[i];
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment