using System;
public class Program
{
public static void Main()
string str = "4eeksforGeeks";
Console.WriteLine(LeftMostRepeatingChar(str));
}
public static int LeftMostRepeatingChar(string str)
int[] arr = new int[256];
int res = -1;
for(var i=str.Length-1; i >= 0; i--)
arr[str[i]]++;
if(arr[str[i]] > 1)
res = i;
//Console.WriteLine(string.Join(", ", arr));
return res;