Skip to content

Instantly share code, notes, and snippets.

@pdolinaj
pdolinaj / Arithmetic Slices.php
Last active August 29, 2015 14:21
Return number of arithmetic slice in a given set - Solution to a problem on CODILITY
//Return number of arithmetic slices in a given set
public function numberOfArithmeticSlicesFromSet(array $A)
{
$numbersCount = count($A);
//mininum length of arithmetic slice is 3
if($numbersCount < 3)
return 0;
$startOfSlice = 0;