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

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Abdulla Ansari
Abdulla Ansari

Written by Abdulla Ansari

Connect with me to enhance yourself from a college guy to a senior software engineer in tech like python, javascript and now generative ai

No responses yet

Write a response