From 2be0e93578d9074ed8e8615c741b513c76406b68 Mon Sep 17 00:00:00 2001 From: jsoud <146140752+jsoud@users.noreply.github.com> Date: Fri, 26 Jan 2024 15:22:44 -0800 Subject: [PATCH] Create WordOrder.py --- Hackerrank/WordOrder.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Hackerrank/WordOrder.py diff --git a/Hackerrank/WordOrder.py b/Hackerrank/WordOrder.py new file mode 100644 index 00000000..3520fa27 --- /dev/null +++ b/Hackerrank/WordOrder.py @@ -0,0 +1,16 @@ +# Enter your code here. Read input from STDIN. Print output to STDOUT +n = int(input()) +wordCount = dict() +for i in range(n): + s = input() + if s in wordCount: + wordCount[s] += 1 + else: + wordCount[s] = 1 + +countList = [] +for value in wordCount.values(): + countList.append(str(value)) + +print(len(wordCount)) +print(' '.join(countList))