Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Mirror Inverse Program in javascript

<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>
Comment

PREVIOUS NEXT
Code Example
Javascript :: refreshapex 
Javascript :: react native uncaught error main has not been registered stackoverflow 
Javascript :: numberformat chakra 
Javascript :: pro side nav react rtl 
Javascript :: hsv to rgb js 
Javascript :: javascript foreach next iteration 
Javascript :: knex js how to group by many items 
Javascript :: eva icons js 
Javascript :: broken image 
Javascript :: Parsing the URL string using the WHATWG API 
Javascript :: how to make react host on https localhost 
Javascript :: how to use script tag in javascript 
Javascript :: javascript object duplicate keys 
Javascript :: react js date range 
Javascript :: sort an array in descending order javascript 
Javascript :: fib numbers javascript 
Javascript :: form submit with ajax 
Javascript :: style mapbox paint data driven 
Javascript :: rest object javascript 
Javascript :: setCount 
Javascript :: button onclick link to another page react 
Javascript :: angular + An unhandled exception occurred: Transform failed with 1 error: 
Javascript :: draw image inside canvas width 100% 
Javascript :: vite build output destination change 
Javascript :: javascript axios response.data.pipe not a function 
Javascript :: Make a card dynamic with Angular JS 
Javascript :: Prevent the wiping of an Array after routing Angular.js 
Javascript :: Calculating state happens to late 
Javascript :: Extract and convert from JSON by Regex 
Javascript :: fields filtering in api from express 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =