Hi there 馃憢

This blog is intended to share my knowledge about software architecture, system design, tools, and techniques for producing high-quality products.

LeetCode - 150 - Count Good Nodes in Binary Tree

The problem Given a binary tree root, a node X in the tree is named good if in the path from root to X there are no nodes with a value greater than X. Return the number of good nodes in the binary tree. Examples Input: root = [3,1,4,3,null,1,5] Output: 4 Explanation: Nodes in blue are good. Root Node (3) is always a good node. Node 4 -> (3,4) is the maximum value in the path starting from the root. Node 5 -> (3,4,5) is the maximum value in the path Node 3 -> (3,1,3) is the maximum value in the path. ...

August 7, 2025 路 3 min 路 Dmytro Chumakov

LeetCode - 150 - Binary Tree Right Side View

The problem Given the root of a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom. Examples Input: root = [1,2,3,null,5,null,4] Output: [1,3,4] Explanation: Input: root = [1,2,3,4,null,null,null,5] Output: [1,3,4,5] Explanation: Input: root = [1,null,3] Output: [1,3] Input: root = [] Output: [] Constraints The number of nodes in the tree is in the range [0, 100]. -100 <= Node.val <= 100 Explanation Let鈥檚 imagine that we have a person on the right side and if we look at the first example, we can see everything on the right side. ...

August 5, 2025 路 4 min 路 Dmytro Chumakov

LeetCode - 150 - Balanced Binary Tree

The problem Given a binary tree, determine if it is height-balanced. A height-balanced binary tree is a binary tree in which the depth of the two subtrees of every node never differs by more than one. Examples Input: root = [3,9,20,null,null,15,7] Output: true Input: root = [1,2,2,3,3,null,null,4,4] Output: false Input: root = [] Output: true Constraints The number of nodes in the tree is in the range [0, 5000]. -10^4 <= Node.val <= 10^4 Explanation From the description of the problem, we learn that we need to find if the tree is height-balanced, and that we can do it by determining if the difference between the height of every single node in the left and right subtrees is no more than 1. ...

July 30, 2025 路 4 min 路 Dmytro Chumakov

LeetCode - 150 - Diameter of Binary Tree

The problem Given the root of a binary tree, return the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path may or may not pass through the root. The length of a path between two nodes is represented by the number of edges between them. Examples ...

July 26, 2025 路 3 min 路 Dmytro Chumakov

LeetCode - 150 - LRU Cache

The problem Design a data structure that follows the constraints of a Least Recently Used (LRU) cache. Implement the LRUCache class: LRUCache(int capacity) Initialize the LRU cache with positive size capacity. int get(int key) Return the value of the key if the key exists, otherwise return -1. void put(int key, int value) Update the value of the key if the key exists. Otherwise, add the key-value pair to the cache. If the number of keys exceeds the capacity from this operation, evict the least recently used key. The functions get and put must each run in O(1) average time complexity. ...

July 22, 2025 路 5 min 路 Dmytro Chumakov