Skip to content

Instantly share code, notes, and snippets.

@rgab1508
Last active November 17, 2019 08:16
Show Gist options
  • Save rgab1508/cad71672089d7ed223e04bf987f178dd to your computer and use it in GitHub Desktop.
Save rgab1508/cad71672089d7ed223e04bf987f178dd to your computer and use it in GitHub Desktop.
nTst = int(input())
for i in range(nTst):
for i in range(nTest):
n = int(input())
arr = input().split(" ")
arr = list(map(int, arr))
se = input()
start, end = int(se.split(" ")[0]), int(se.split(" ")[1])
val = start
for i in range(n-1):
#val = start
start = arr[val-1]
val = start
if start == end:
print("Yes")
else:
print("No")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment