Created
August 7, 2018 07:31
-
-
Save gegagome/b0f65e08d7529d3963b0d98851781821 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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