DSA

Find Intersection of Two Singly Linked Lists

You are given two singly linked lists that intersect at some node. Your task is to find and return the…

11 months ago

Minimum Cost to Paint Houses with K Colors

A builder plans to construct N houses in a row, where each house can be painted in K different colors.…

11 months ago

Longest Absolute Path in File System Representation

Find the length of the longest absolute path to a file within the abstracted file system. The length is measured…

11 months ago

Efficient Order Log Storage

You manage an e-commerce website and need to keep track of the last N order IDs in a log. Design…

12 months ago

Select a Random Element from a Stream

You are given a stream of elements that is too large to fit into memory. Write an algorithm to select…

12 months ago

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…

1 year 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…

1 year ago

Staircase Climbing Ways

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

1 year ago

Job Scheduler Implementation

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

1 year 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…

1 year ago