DEV Community

Abdulla Ansari
Abdulla Ansari

Posted on • Edited on

2 2

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

Hi Programmers,

I hope you are doing well, so in todays 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)
Enter fullscreen mode Exit fullscreen mode

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

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

By me a Coffee

My other Blog Website over Technology

My YouTube Vlog Channel

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

AWS Security LIVE!

Hosted by security experts, AWS Security LIVE! showcases AWS Partners tackling real-world security challenges. Join live and get your security questions answered.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️