Hassan Raza

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…

5 days 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…

6 days ago

Staircase Climbing Ways

There is a staircase with N steps, and you can ascend either 1 step or 2 steps at a time.…

2 weeks ago

Autocomplete System Implementation

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

2 weeks ago

Job Scheduler Implementation

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

2 weeks 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…

2 weeks 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…

2 weeks ago

Count Decoding Ways for Encoded Messages

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

2 weeks 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…

3 weeks 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):…

3 weeks ago