This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
To fix this bug, backup your changes and execute those commands at the root of git repository to reset git index: | |
rm .git/index | |
git reset |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$neededObject = array_filter( | |
$arrayOfObjects, | |
function ($e) use ($searchedValue) { | |
return $e->id == $searchedValue; | |
} | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Find the smallest interval (minimum difference) between the numbers of an array. | |
* | |
* @param array $numbers | |
* @return {Int} $diff | |
*/ | |
function findSmallestInterval(array $numbers) | |
{ | |
// Number of items in the array | |
$length = count($numbers); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
/** | |
* Performs the binary search over | |
* sorted array | |
* | |
* It should perform this operation in O(logn) | |
*/ | |
function binary_search(array $sortedArray, $searchElement) { | |
// Check if array is sorted | |
$min_index = 0; |