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
class TreeNode { | |
constructor(value) { | |
this.value = value; | |
this.left = null; | |
this.right = null; | |
} | |
} | |
class BainaryTree { | |
constructor(root) { |
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 deepEquals(value1, value2) { | |
if(typeof value1 !== typeof value2) return false; | |
if(value1 === value2) return true; | |
if (typeof value1 !== "object" && typeof value2 !== "object") { | |
// NaN type validation; | |
const [isValue1NaN, isValue2NaN] = [...arguments].map((value) => Number.isNaN(value) && typeof value === "number"); | |
if (isValue1NaN && isValue2NaN) return 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
// list node constructor | |
function ListNode(val) { | |
this.next = null; | |
this.value = val; | |
} | |
const MyLinkedList = function () { | |
this.head = null; // the head of the linked lsit | |
this.size = 0; // use the size to have addtional useful validation |
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
#include <iostream> | |
#include <math.h> | |
int subsequence (int arr[],int length) | |
{ | |
int counter = 0; | |
// how many times iterate (extend from this formula => 2^n - 1) | |
int power = pow(2, length); |
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
#include <iostream> | |
int subsequence(int arr[], int length) | |
{ | |
// counter the number of Subsequences | |
int counter = 0; | |
for (size_t i = 0; i < length; i++) | |
{ |