From 9e7d08ded818ede37d010db554d54395be5edb6d Mon Sep 17 00:00:00 2001 From: Rishabh Singh Chauhan <143814425+Rsc2414@users.noreply.github.com> Date: Sat, 19 Jul 2025 20:52:58 +0530 Subject: [PATCH] Update 002. No Idea!.py --- Python/04. Sets/002. No Idea!.py | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/Python/04. Sets/002. No Idea!.py b/Python/04. Sets/002. No Idea!.py index 080b45b..f1f0a1b 100644 --- a/Python/04. Sets/002. No Idea!.py +++ b/Python/04. Sets/002. No Idea!.py @@ -1,9 +1,25 @@ -# Problem: https://www.hackerrank.com/challenges/no-idea/problem -# Score: 50 +#By @Rsc2414 +# Read the input but ignore the first line (not needed here) +_ = input() +# Read the array of elements +elements = input().split() -_ = input() -array = input().split() -like = set(input().split()) -dislike = set(input().split()) -print(sum((i in like) - (i in dislike) for i in array)) +# Read the set of elements you like +liked_elements = set(input().split()) + +# Read the set of elements you dislike +disliked_elements = set(input().split()) + +# Initialize happiness score +happiness = 0 + +# Go through each element in the array +for item in elements: + if item in liked_elements: + happiness += 1 # Add 1 if it's in the liked set + elif item in disliked_elements: + happiness -= 1 # Subtract 1 if it's in the disliked set + +# Print the final happiness score +print(happiness)