79286396

Date: 2024-12-17 00:22:18
Score: 1
Natty:
Report link

Simple and Performing Solution - O(n)

$array = ["START","a","a","a","START","b","b","b","START","c","c","c"];
$res = [];
$index = 0;
foreach ($array as $val) {
    if ($val === 'START') {
        $index++;
    } else if ($index > 0) {
        $res[$index - 1][] = $val;
    }
}
var_dump($res);
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Ali Mousavi