String has same characters at same position
public class Solution
{
public int[] solution(string[] S)
{
//ensure string is not null here
if (S?.Length > 0)
{
Dictionary<char, Dictionary<int, int>> dict = [];
for (int i = 0; i < S.Length; i++)
{
for (int j = 0; j < S[i].Length; j++)
{
if (!dict.ContainsKey(S[i][j]))
{
dict[S[i][j]] = [];
}
if (dict[S[i][j]].ContainsKey(j))
{
return [dict[S[i][j]][j], i, j];
}
else
{
dict[S[i][j]][j] = i;
}
}
}
}
return [];
}
}Last updated