coderz.py

Keep Coding Keep Cheering!

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 first intersecting node.

March 11, 2025 | Data Structure, Google | No comments

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. The goal is to minimize the total painting cost, ensuring that no two adjacent houses have the same color.

March 9, 2025 | Data Structure, dsa, Facebook | No comments

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 in characters.

February 19, 2025 | dsa, Google | No comments

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 a data structure that supports the following operations efficiently:

February 6, 2025 | Data Structure, dsa, Twitter | No comments

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 a random element from the stream with equal probability

February 3, 2025 | Algorithm, dsa, Twitter | No comments

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 value of π to three decimal places.

January 17, 2025 | dsa, DSA Sheet, Google | No comments

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 s that contains at most k distinct characters.

January 16, 2025 | Amazon, dsa, DSA Sheet | No comments

Staircase Climbing Ways

There is a staircase with N steps, and you can ascend either 1 step or 2 steps at a time. Write a function to calculate the number of unique ways to climb the staircase. The sequence of steps matters.

January 11, 2025 | Amazon, Data Structure, dsa | No comments

Autocomplete System Implementation

Build an autocomplete system that, given a query string s and a set of possible query strings returns all strings from the set that start with s as a prefix.

January 10, 2025 | dsa, DSA Sheet, Twitter | No comments

Job Scheduler Implementation

Design a job scheduler that accepts a function f and an integer n. The scheduler should execute the function f after a delay of n milliseconds.

January 9, 2025 | Apple, dsa, DSA Sheet | No comments

Advertisement