December 04, 2024 |43.0K Views

    Find first non-repeating character of given string

    Explore Courseexplore course icon
    Description
    Discussion

    To find the first non-repeating character in a string, you can use different approaches. A naive solution involves two nested loops, checking each character's frequency. A more efficient method uses a frequency array with two traversals of the string. Alternatively, a single traversal can be used by storing character indices and marking repeats. If no non-repeating character is found, return '$'. These methods ensure optimal performance for the problem.

    For more details, check out the full article: Find first non-repeating character of given string.