DSA Sheet

Estimate π Using Monte Carlo Method

The formula for the area of a circle is given by πr². Use the Monte Carlo method to approximate the…

10 months ago

Longest Substring with K Distinct Characters

Given an integer k and a string s, write a function to determine the length of the longest substring in…

10 months ago

Autocomplete System Implementation

Build an autocomplete system that, given a query string s and a set of possible query strings returns all strings…

10 months ago

Job Scheduler Implementation

Design a job scheduler that accepts a function f and an integer n. The scheduler should execute the function f…

10 months ago

Largest Sum of Non-Adjacent Numbers

Problem Statement (Asked By Airbnb) Given a list of integers, write a function to compute the largest sum of numbers…

10 months ago

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