Problem Statement:-
There are a number of people who will be attending ACM-ICPC World Finals. Each of them may be well versed in a number of topics. Given a list of topics known by each attendee, presented as binary strings, determine the maximum number of topics a 2-person team can know. Each subject has a column in the binary string, and a ‘1’ means the subject is known while ‘0’ means it is not. Also determine the number of teams that know the maximum number of topics. Return an integer array with two elements. The first is the maximum number of topics known, and the second is the number of teams that know that number of topics.

An interesting hackerrank problem which made me learn bit manipulation and operation.Here we have to find the number of best team combination which know maximum number of subject among the given subject list.Lets move towards the code.

Photo by Josh Calabrese on Unsplash

First we will declare two variables max_score and team and give them an initial value of 0.Then we will run two nested for loop, the first loop will run till the number of attendees i.e “n” and second loop will start from “n+1” to number of attendees. Using two for loop we will be able to perform OR-operation and store it in x and we will count the number of “1” in the result in x and store it in “score”.if score is greater than max_score in that iteration we insert the value of score in max_score and make team equal to 1.we will again check if the value in score and max_score is equal then we will increment the value of team by 1.At last we will return the max_score and team value.

Never be in a hurry; do everything quietly and in a calm spirit. Do not lose your inner peace for anything whatsoever, even if your whole world seems upset”.An excellent quote which teachs us that good things take time to happen but will surely happen if we keep working and maintain the inner peace.Keep hustling and keep moving….(cheers:-PN)

Work in progress