Posts

Hakerrank codes

 import requests

def longestEvent(organizer, genre):

    page = 1

    max_duration = -1

    answer = None

    while True:

        url = f"https://jsonmock.hackerrank.com/api/events?page={page}"

        res = requests.get(url).json()

        for event in res["data"]:

            if event["organized_by"] == organizer and genre in event["genres"]:  

                duration = event["duration"]

                event_id = event["id"]

                if duration > max_duration:

                    max_duration = duration

                    answer = event_id          

                elif duration == max_duration:

                    if answer is None or event_id < answer:

                        answer = event_id

        if page >= res["total_pages"]:

            break     

        page += 1

    return answer if answer else "-1"


https://jsonmock.hackerrank.com/api/football_teams?league={league_name}&page={num}

Post a Comment

Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.