class Solution
{
public:
//Function to find the first non-repeating character in a string.
char nonrepeatingCharacter(string S)
{
int chars=256;
int n=S.size();
int arr[chars];
fill(arr,arr+chars,0);
for(int i=0;i<n;i++)
{
arr[S[i]]++;
}
for(int i=0;i<256;i++)
{
if(arr[S[i]]==1)
{
return (char)S[i];
}
}
return '$';
//Your code here
}
};