We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
x=int(input())# say 6y=list(map(int,input().strip().split()))# 5 1 2 3 4 2# d1 is the original func as # d2 is the reverse funcd1=d2={}# d1 is {1: 5, 2: 1, 3: 2, 4: 4, 5: 3}foriiny:d1[y.index(i)+1]=i# Take all values of d1vals=list(d1.values())# Getting d2 as {1: 5, 2: 1, 3: 2, 4: 4, 5: 3}foriinvals:d2[vals.index(i)+1]=i# Include the condition for intersecting elements making it non bijective in natureprint((len((set(d1.items())andset(d2.items())))==x)and"YES"or"NO")
lines of code...
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Security Involution
You are viewing a single comment's thread. Return to all comments →
I have written a bit more
lines of code...