Skip to content

Instantly share code, notes, and snippets.

View alguerocode's full-sized avatar
🎯
Focusing

salah alhashmi alguerocode

🎯
Focusing
View GitHub Profile
@alguerocode
alguerocode / menu.cpp
Created July 5, 2022 08:24
C++ menu system using ncurses
#include <ncurses.h>
int main()
{
initscr();
refresh();
noecho();
WINDOW *menuwin = newwin(10, 40, 2, 4);
box(menuwin, 0, 0);
class TreeNode {
constructor(value) {
this.value = value;
this.left = null;
this.right = null;
}
}
class BainaryTree {
constructor(root) {
@alguerocode
alguerocode / deep-equal.js
Last active June 22, 2022 07:23
deep equal operation in javascript
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;
@alguerocode
alguerocode / linked-list.js
Created June 21, 2022 07:55
understandable singly linked list in javascript
// 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
@alguerocode
alguerocode / subsequence.cpp
Created June 7, 2022 11:11
a function that generate and return count of how many subsequences of an array
#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);
@alguerocode
alguerocode / main.cpp
Created June 6, 2022 11:10
c++ function to extract all the Subsequences in the array of numbers ranged between 1 to 4
#include <iostream>
int subsequence(int arr[], int length)
{
// counter the number of Subsequences
int counter = 0;
for (size_t i = 0; i < length; i++)
{