<script>
// JavaScript implementation of the approach
// Function that returns true if
// the array is mirror-inverse
function isMirrorInverse(arr) {
for (i = 0; i < arr.length; i++) {
// If condition fails for any element
if (arr[arr[i]] != i)
return false;
}
// Given array is mirror-inverse
return true;
}
// Driver code
var arr = [ 1, 2, 3, 0 ];
if (isMirrorInverse(arr))
document.write("Yes");
else
document.write("No");
// This code contributed by Rajput-Ji
</script>