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

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

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

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 the root of a binary tree, determine how many unival subtrees it contains.

For example, the following tree has 5 unival subtrees:

January 6, 2025 | Binary Tree, dsa, DSA Sheet, Google | No comments

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 prev pointers, each node contains a single field called both, which stores the result of the XOR operation on the memory addresses of the next and previous nodes.

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

Serialize and Deserialize a Binary Tree

Given the root of a binary tree, create two functions:

serialize(root) – Converts the binary tree into a string representation.

deserialize(s) – Reconstructs the binary tree from its string representation.

January 1, 2025 | array, dsa, DSA Sheet, Google | No comments

Advertisement