Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

Mirror Inverse Program in php

<?php
// PHP implementation of the approach
 
// Function that returns true if
// the array is mirror-inverse
function isMirrorInverse($arr)
{
    for ($i = 0; $i < sizeof($arr); $i++)
    {
 
        // If condition fails for any element
        if ($arr[$arr[$i]] != $i)
            return false;
    }
 
    // Given array is mirror-inverse
    return true;
}
 
// Driver code
$arr = array(1, 2, 3, 0);
if (isMirrorInverse($arr))
    echo("Yes");
else
    echo("No");
 
// These code is contributed by Code_Mech.
?>
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #Mirror #Inverse #Program #php
ADD COMMENT
Topic
Name
6+2 =