Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

Mirror Inverse Program in c#

// C# implementation of the approach
using System;
 
class GFG
{
     
    // Function that returns true if
    // the array is mirror-inverse
    static bool isMirrorInverse(int []arr)
    {
        for (int 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
    static public void Main ()
    {
        int []arr = { 1, 2, 3, 0 };
        if (isMirrorInverse(arr))
            Console.WriteLine("Yes");
        else
            Console.WriteLine("No");
    }
}
 
// This code is contributed by ajit...
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #Mirror #Inverse #Program
ADD COMMENT
Topic
Name
3+7 =