HackerRank Python- No Idea

There is an array of n integers. There are also 2 disjoint sets, A and B, each containing m integers. You like all the integers in set A and dislike all the integers in set B. Your initial happiness is 0.

  1. # Enter your code here. Read input from STDIN. Print output to STDOUT
  2. if __name__ == "__main__":
  3. happiness = 0
  4. n, m = map(int, input().strip().split(' '))
  5. arr = list(map(int, input().strip().split(' ')))
  6. good = set(map(int, input().strip().split(' ')))
  7. bad = set(map(int, input().strip().split(' ')))
  8. for el in arr:
  9. if el in good:
  10. happiness += 1
  11. elif el in bad:
  12. happiness -= 1
  13. print(happiness)
Please click on the like button if it worked

Solution not working or have any suggestions? Please send an email to [email protected]

donate a cup of tea :)

Join Our Facebook Group

Share this solution


Codesadda.com is your home of programming solutions, tutorials, video tutorials and much more. Sign Up for our weekly newsletter to get update about new content.

Like us on Facebook | Connect with us on LinkedIn | Subscribe our Channel on Youtube