Skip to content

Instantly share code, notes, and snippets.

@AbeEstrada
AbeEstrada / levelOrder.js
Created September 2, 2025 02:58
Exercise: Tree Level Order Traversal
// Breadth First Search (BFS)
function levelOrder(root) {
if (!root) return;
const queue = [root];
const result = [];
let index = 0;
while (index < queue.length) {
const currentNode = queue[index++];
result.push(currentNode.data);
if (currentNode.left) queue.push(currentNode.left);
@AbeEstrada
AbeEstrada / isBalanced.js
Last active September 2, 2025 02:48
Exercise: Balanced Brackets
function isBalanced(s) {
const pattern = /\[\]|\(\)|\{\}/g;
while (pattern.test(s)) {
s = s.replace(pattern, "");
}
return s ? "NO" : "YES";
}
@AbeEstrada
AbeEstrada / decodeHuff.js
Last active September 2, 2025 00:39
Exercise: Tree Huffman Decoding
function analyzeFrequencies(str) {
const frequencies = {};
for (const char of str) {
frequencies[char] = (frequencies[char] || 0) + 1;
}
return frequencies;
}
// Factory function for leaf node
function createLeaf(char, frequency) {
return {
@AbeEstrada
AbeEstrada / checkBTS.js
Created September 2, 2025 00:19
Exercise: Is This a Binary Search Tree?
class Node {
constructor(data) {
this.data = data;
this.left = null;
this.right = null;
}
}
function insert(root, data) {
if (root === null) {
return new Node(data);
@AbeEstrada
AbeEstrada / btLCA.js
Created September 2, 2025 00:15
Exercise: Binary Search Tree Lowest Common Ancestor
class Node {
constructor(data) {
this.data = data;
this.left = null;
this.right = null;
}
}
function insert(root, data) {
if (root === null) {
return new Node(data);
@AbeEstrada
AbeEstrada / heightBinaryTree.js
Last active September 2, 2025 02:20
Exercise: Height of a Binary Tree
function height(root) {
if (root === null) return -1;
return 1 + Math.max(height(root.left), height(root.right));
}
@AbeEstrada
AbeEstrada / balancedForest.js
Created September 2, 2025 00:12
Exercise: Balanced Forest
function createNodes(costs) {
return costs.map(cost => ({
cost,
adj: [],
visited: false,
solved: false
}));
}
function buildGraph(nodes, edges) {
for (let [a, b] of edges) {
@AbeEstrada
AbeEstrada / fedora-sway.md
Last active July 6, 2025 19:53
Fedora Sway Spin Config

Update packages

sudo dnf check-update
sudo dnf update

Change shell

How to compile

zig build -Doptimize=ReleaseFast

Requires: (Fedora) sudo dnf install gcc-c++

#!/bin/zsh
usage() {
echo "https://github.com/facefusion/facefusion"
echo "Usage: $0 -s source_image -t target_image [-r reference_face_position] [-e]"
echo " -s: Path to the source image"
echo " -t: Path to the target image"
echo " -r: Reference face position (default: 0)"
echo " -e: Toggle to remove the face enhancer (optional)"
exit 1