data structure

Count Unival Subtrees in a Binary Tree

A unival tree (short for "universal value tree") is a tree in which all nodes have the same value. Given…

10 months ago

Count Decoding Ways for Encoded Messages

Problem Statement (Asked By Facebook) Given the mapping a = 1, b = 2, ..., z = 26, and an…

10 months ago

Implement an XOR Linked List

An XOR-linked list is a memory-efficient version of a doubly linked list. Instead of each node storing separate next and…

10 months ago

Construct and Deconstruct a Pair

Problem Statement (Asked By Jane Street) The function cons(a, b) creates a pair of two elements. Implement two functions: car(pair):…

10 months ago

Find the Smallest Missing Positive Integer

Problem Statement (Asked By Stripe) You are given an array of integers. Your task is to find the smallest missing…

10 months ago

Serialize and Deserialize a Binary Tree

Given the root of a binary tree, create two functions: serialize(root) - Converts the binary tree into a string representation.…

10 months ago

Product of Array Except Self

Problem Statement (Asked By Uber) Given a list of integers, return a new list such that each element at index…

10 months ago

Two Sum: Check for Two Numbers with Sum K

Problem Statement (Asked By Google) Given a list of integers and a target number k, determine if there exist two…

10 months ago

DSA: Heap

A heap is a specialized tree-based data structure that satisfies the heap property. It is commonly used to implement priority…

2 years ago

DSA: Trie

What is a Trie in DSA? A trie, often known as a prefix tree, is a tree-like data structure used…

2 years ago