ChefWatson uses social network

Basically, here it's just a simple implementation part that we have to handle, and also we gotta understand how to approach the logic of giving more priority to the friends posts and then in that too taking the posts on the basis of their popularity and for the rest of the normal posts(the posts apart from those of the Friends) they will just be taken on basis of popularity. 

With Python these kinds of problems are just a piece of cake, although I will be implementing this in C++ too, well we should mostly prefer Python over C++ for such kinds of direct problems and also because the Constraints were quite low it was not a problem with Python.

Explanation:-

For the implementation, I think the code is quite understandable and specially I took the variable names like this because I am trying to work on taking better variable names for my codes.

Just single logic, take the inputs and divide them into the friends posts and normal posts, then just Sort both of them(don't forget to sort on them in Decreasing order) that's it.

Code:-

'''
Input:
2 4
1 2
1 1 WhoDoesntLoveChefBook
2 2 WinterIsComing
3 10 TheseViolentDelightsHaveViolentEnds
4 3 ComeAtTheKingBestNotMiss

Output:
WinterIsComing
WhoDoesntLoveChefBook
TheseViolentDelightsHaveViolentEnds
ComeAtTheKingBestNotMiss
'''


print(input("Enter your name: "))
# # Taking no. of friends(n) and the total no. of posts(m)
# n,m=map(int,input().split())

# # Taking indentifiers of Friends
# friends=list(map(int,input().split()))

# # Taking m posts alongwith their identifiers and popularity
# for _ in range(m):
#     identifier,popularity,post=input().split()
#     identifier=int(identifier)
#     popularity=int(popularity)
#     print(f"{identifier} with {popularity}")



Comments

Popular Posts