DEV Community

Discussion on: Daily Challenge #213 - Are they the "same"?

Collapse
 
fsarikayaa profile image
Ferhat Sarıkaya • Edited

Php solution

 function comp($a1, $a2)
        {
            if ( is_null($a1) || is_null($a2) )
                return false;

            $t = array_map(function($v) {
                return $v * $v;
            }, $a1);

            sort($a2);
            sort($t);
            return $a2 == $t;
        }
Enter fullscreen mode Exit fullscreen mode