Non Repeating Character

PHOTO EMBED

Wed Sep 28 2022 18:24:48 GMT+0000 (Coordinated Universal Time)

Saved by @Ranjan_kumar

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
       
    }

};
content_copyCOPY

very important

https://practice.geeksforgeeks.org/problems/non-repeating-character-1587115620/1