Skip to content

Instantly share code, notes, and snippets.

View jochemd's full-sized avatar

Jochem van Dieten jochemd

  • we are north
  • Rotterdam, NL
View GitHub Profile
@jochemd
jochemd / getSubseries.php
Created November 9, 2014 20:20
For a given array and a given threshold, return the subarray which contains the longest run of consecutive numbers which - in total - are equal-to or less than the threshold. (see http://blog.adamcameron.me/2014/11/something-for-weekend-wee-code-quiz-in.html)
<?php
$threshold = 500;
// Test cases
$tests = [
// empty array
[[], []]
// one element array
, [[1], [1]]
// more element array
, [[1,2,3], [1,2,3]]