Skip to content

Instantly share code, notes, and snippets.

View fre2mansur's full-sized avatar

Mansur Rahamathullah fre2mansur

  • Auroville Consuting
  • Auroville
View GitHub Profile
@fre2mansur
fre2mansur / answer1.php
Last active July 27, 2019 09:08
My answers [1-4]
<?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
@fre2mansur
fre2mansur / answer1.php
Created July 27, 2019 08:40
My answers
/*
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
@fre2mansur
fre2mansur / answer1.php
Created July 27, 2019 07:28
My answers, please read the readme.md for my explanations
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
@fre2mansur
fre2mansur / answer1.php
Created July 27, 2019 07:26
Getting the next fibonacci number of given any number
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
@fre2mansur
fre2mansur / answer3.php
Created July 27, 2019 07:15
Step one: check the given number is fibonacci or not.
$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--;