Sort by

recency

|

14 Discussions

|

  • + 0 comments

    from collections import deque, defaultdict

    def maximize_skillsets(s, w, people_skills, wizards_transformations): # Start by creating a queue for BFS queue = deque() visited = set()

    # Initialize the graph for transformations
    graph = defaultdict(list)
    
    # Build the graph for wizard transformations
    for wizard in wizards_transformations:
        list_A, list_B = wizard
        for a in list_A:
            for b in list_B:
                graph[a-1].append(b-1)
                graph[b-1].append(a-1)
    
    # Add all current skill sets with people to the queue
    for i in range(s):
        if people_skills[i] > 0:
            queue.append(i)
            visited.add(i)
    
    # Perform BFS to transform skills
    while queue:
        current_skill = queue.popleft()
        for neighbor in graph[current_skill]:
            if neighbor not in visited:
                visited.add(neighbor)
                people_skills[neighbor] += 1
                queue.append(neighbor)
    
    # Count the number of distinct skill sets with people
    return sum(1 for count in people_skills if count > 0)
    

    if name == "main": # Reading input s, w = map(int, input().split()) people_skills = list(map(int, input().split()))

    wizards_transformations = []
    for _ in range(w):
        list_A = list(map(int, input().split()))[1:]
        list_B = list(map(int, input().split()))[1:]
        wizards_transformations.append((list_A, list_B))
    

    My code is correct as its giving right output after running but failed 14/25 Test Cases What is wrong in it, kindly help guys?

    result = maximize_skillsets(s, w, people_skills, wizards_transformations)
    print(result)
    
  • + 0 comments

    Discover the key strategies for effective training in the army with our comprehensive guide, tailored to enhance military readiness and skills. To support your training efforts, we’re offering a special promotion: receive a set of custom tote bags with every guide purchase. These bags are perfect for carrying your training materials and gear, combining practicality with style as you prepare and execute successful training programs for the army."

  • + 0 comments

    Here is my solution in java, javascript, python, C, C++, Csharp HackerRank Training the army Problem Solution

  • + 0 comments

    Here is the solution of Training the army Click Here

  • + 0 comments

    Here is problem solution - https://programs.programmingoneonone.com/2021/07/hackerrank-training-the-army-problem-solution.html