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 /* | |
Explanation | |
This is very simple i just compare the two arrays if the second array is in first array i make it to show true | |
*/ | |
function isSubset($array1, $array2) { | |
echo (!array_diff($array2, $array1) ? "true" : "false"); | |
} | |
//output | |
isSubset(array("A","B","C","D","E"), array("A","E","D")); // true |
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
/* | |
Explanation | |
This is very simple i just compare the two arrays if the second array is in first array i make it to show true | |
*/ | |
function isSubset($array1, $array2) { | |
echo (!array_diff($array2, $array1) ? "true" : "false"); | |
} | |
//output | |
isSubset(array("A","B","C","D","E"), array("A","E","D")); // true |
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
function isSubset($array1, $array2) { | |
echo (!array_diff($array2, $array1) ? "true" : "false"); | |
} | |
//output | |
isSubset(array("A","B","C","D","E"), array("A","E","D")); // true | |
isSubset(array("A","B","C","D","E"), array("A","D","Z")); // false | |
isSubset(array("A","D","E"), array("A","A","D","E")); // true |
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
function isSubset($array1, $array2) { | |
echo (!array_diff($array2, $array1) ? "true" : "false"); | |
} | |
//output | |
isSubset(array("A","B","C","D","E"), array("A","E","D")); // true | |
isSubset(array("A","B","C","D","E"), array("A","D","Z")); // false | |
isSubset(array("A","D","E"), array("A","A","D","E")); // true |
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
$input = array(1,22,9,0); | |
var_dump(nextFibonacci($input)); //output [2,34,13] | |
function nextFibonacci($input) { | |
foreach($input as $i) { | |
while($i>=0) { | |
$store[] = $i; | |
if(isFibonacci($i)) | |
break; | |
$i--; |