/**
* Simple algorithm to remove the longest non-repeating string from an unordered string
* Time Space complexity O (n)
* 2016/06/18
*/
$str = ";
$arr = [' A ', ' B ', ' C ', ' d ', ' e ', ' f ', ' g ', ' h ', ' I ', ' j ', ' K ', ' l ', ' m ', ' n ', ' o ', ' P ', ' Q ', ' R ', ' s ', ' t ', ' u ', ' V ', ' w ', ' y ', ' z '];
for ($i =0; $i <100; $i + +):
$str. = $arr [Intval (rand (0,18))];
ENDfor;
printf ("%s", $STR);
function Getstronlylengthreturn ($STR)
{
$arr = [];
$RETURNARR = [];
$strLen = StrLen ($STR);
for ($i =0; $i < $strLen; $i + +):
$arr [$str {$i}] = $str {$i};
if (Isset ($str {$i +1}) && isset ($arr [$str {$i +1}])://Prevent notice reminders from appearing
$RETURNARR [Count ($arr)] = implode ($arr, ");
$arr = [];
endif
ENDfor;
Krsort ($RETURNARR);
Return Array_shift ($RETURNARR);
}
The above describes the simple algorithm from an unordered string to remove the longest piece of non-repeating string, including the aspects of the content, I hope to be interested in PHP tutorial friends helpful.