⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions interviews/python/Solve.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
def Solve(encode):
my_hashmap = {}

# count the charcter frequency
for i in encode:
my_hashmap[i] = my_hashmap.get(i,0) + 1

res = []

# append tuple of value and key into list res
for key, value in my_hashmap.items():
res.append((value, key))
# return res
return res

def main():
print(Solve(['t', 't', 't', 't', 'b', 'c', 'c', 'a', 'a', 'd', 'r', 'r', 'r', 'r']))

if __name__ == "__main__":
main()