How to use 'find repeated characters in a string python' in Python

Every line of 'find repeated characters in a string python' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
14def first_non_repeated_character(s):
15 """O(2n) == O(n)"""
16 char_count_map = collections.defaultdict(lambda: 0)
17 for ch in s: # O(n)
18 char_count_map[ch] += 1
19 for ch in s: # O(n)
20 if char_count_map[ch] == 1:
21 return ch
22 return None

Related snippets