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

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

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

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 i of the new list is the product of all the elements in the original list except the one at i. For instance, if the input is [1, 2, 3, 4, 5], the expected output […]

December 30, 2024 | Algorithm, array, Data Structure, dsa, Uber | No comments

DSA: Heap

A heap is a specialized tree-based data structure that satisfies the heap property. It is commonly used to implement priority queues and efficient sorting algorithms like heap sort.

June 10, 2023 | Algorithm, Data Structure | No comments

DSA: Trie

What is a Trie in DSA? A trie, often known as a prefix tree, is a tree-like data structure used for fast string searching and prefix matching. It allows for the quick retrieval of words or keys connected with each node. The word Trie is derived from reTRIEval, which means finding something or obtaining it.  […]

May 31, 2023 | Data Structure | No comments

Trees: Lowest Common Ancestor

What is the Lowest Common Ancestor? In a tree, the lowest common ancestor (LCA) of two nodes, n1 and n2, is the shared ancestor located farthest from the root and has both n1 and n2 as descendants. Properties of the Lowest Common Ancestor: An LCA can be one of the input nodes themselves if one […]

May 30, 2023 | Data Structure | No comments

Binary Search Tree (BST)

A Binary Search Tree (BST) is a type of binary tree that satisfies the following properties: For any node in the tree, all values in its left subtree are less than its value. For any node in the tree, all values in its right subtree are greater than its value. The left and right subtrees […]

May 29, 2023 | Data Structure | No comments

Types of Views & Binary Trees

In binary trees, the views and types refer to different perspectives and classifications of the tree structure. Types of Views in Binary Tree are : Horizontal View: The horizontal view of a binary tree shows the nodes from left to right at each level. Nodes at the same level are listed in the order of their […]

May 29, 2023 | Data Structure | No comments

Advertisement