Skip to content

Instantly share code, notes, and snippets.

@hosjiu1702
Created January 6, 2021 07:35
Show Gist options
  • Save hosjiu1702/a36759f88968a7656a1bde7436c7cc69 to your computer and use it in GitHub Desktop.
Save hosjiu1702/a36759f88968a7656a1bde7436c7cc69 to your computer and use it in GitHub Desktop.
Solution for problem 5 (FTech Interview)
"""
Author: hosjiu
Email: hosjiu1702@gmail.com
This python script is tested on Python 3.6.10 (on my local machine)
but it can still works for another python version >3.6
"""
from typing import List
def solve(arr: List) -> List:
# Join strings
end_string = ''
for string in arr:
end_string += string
s = set()
count_dict = {}
for c in end_string:
# If the char was not inside the set before
if not c in s:
s.add(c)
count_dict[c] = 1
# Otherwise we update number of its occurrences
else:
count_dict[c] += 1
ret = [k for k, v in count_dict.items() if v >= 3]
return ret
if __name__ == '__main__':
test_case_ex = ['bella', 'hosjiu', 'something', 'went', 'wrong']
print(solve(test_case_ex))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment