package
0.0.0-20211003111303-bf095942a6eb
Repository: https://github.com/tlboright/golang-interview.git
Documentation: pkg.go.dev

# README

firstNonDuplicate

Problem Definition

Given a string, find its first non-repeating character

Given a string, find the first non-repeating character in it. For example, if the input string is “GeeksforGeeks”, then output should be ‘f’ and if input string is “GeeksQuiz”, then output should be ‘G’.

Questions

  • Is there a specific time / space complexity you want it in?
  • How do you want me to handle an empty input?

Complexity

  • The time complexity of this problem is O(2n) since in the worst case we could loop through the string twice. This reduces to O(n).
  • The space complexity of this problem is O(n), since if every character in the string is different, the hash would contain each character.