Last active
November 3, 2017 07:48
-
-
Save HoangPV/960cca249b4cbf0fef2332438ff8d7ee to your computer and use it in GitHub Desktop.
MaxiLenDiff.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace CodeBundle\Functions; | |
/** | |
* Class MaxiLenDiff | |
* @package CodeBundle\Functions | |
* @see https://www.codewars.com/kata/maximum-length-difference/train/php | |
*/ | |
class MaxiLenDiff | |
{ | |
function mxdiflg( $s1, $s2 ) | |
{ | |
if (empty($s1) || empty($s2)) return -1; | |
$s1 = array_map('strlen', $s1); | |
$s2 = array_map('strlen', $s2); | |
return max(abs(max($s1) - min($s2)), abs(min($s1) - max($s2))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment