Skip to content

Instantly share code, notes, and snippets.

@HoangPV
Last active November 3, 2017 07:48
Show Gist options
  • Save HoangPV/960cca249b4cbf0fef2332438ff8d7ee to your computer and use it in GitHub Desktop.
Save HoangPV/960cca249b4cbf0fef2332438ff8d7ee to your computer and use it in GitHub Desktop.
MaxiLenDiff.php
<?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