HackerRank | Count max concurrency of a word in a given list of sentences

Abdulla Ansari
1 min readDec 3, 2022

--

Hi Programmers,

I hope you are doing well, so in today's session, we are again back with a list question of python. So let’s understand the problem first then we will move further.

input = [“i am a good programmer”, “i am also a good person”, “Passing with good marks is my hobby”]

output = good : 3 times

new_lst = []
new_dict = {}

for sentence in input_data:
new_lst += sentence.split()

for word in new_lst:
if word in new_dict:
new_dict[word] += 1
else:
new_dict[word] = 1

word_name = max(new_dict, key=new_dict.get)
word_count = new_dict[word_name]
print(word_name, word_count)

I hope you have got an idea of how you can solve this problem. There might be more solutions for this problem if I will get any ideas, I will surely update this post.

Thanks for your valuable time. You can like my post
you can,

For me a Coffee

My other Blog Website over Technology

My YouTube Vlog Channel

--

--

Abdulla Ansari

A professional software engineer and passionate technical writer