Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions Python/04. Sets/002. No Idea!.py
Original file line number Diff line number Diff line change
@@ -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)