You are viewing a single comment's thread. Return to all comments →
Python solution:
n = int(input().strip()) Y = [int(d) for d in input().strip().split()] f = {x+1: y for x, y in enumerate(Y)} print('YES' if all(f[f[y]] == y for y in Y) else 'NO')
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 →
Python solution: