CodeWithMagesh

Articles

Browse all published articles from our writers

Combination sum
dsaJuly 23, 2025

Combination sum

this is combination sum problem

magesh
magesh
Subtree of another tree
dsaMay 22, 2025

Subtree of another tree

In this article, we break down Leetcode 572: Subtree of Another Tree in the simplest way possible—perfect for beginners and even kids learning trees for the first time. You’ll learn what a subtree really means through easy-to-understand examples, including both valid and invalid cases. We walk through the problem intuition, explain the recursive approach step by step, and provide clean Python code that compares two trees node by node. Along the way, we also cover the time and space complexity, helping you understand not just how the solution works, but why it works. If you're trying to build a solid foundation in binary trees and recursion, this guide is a must-read.

magesh
magesh
How to Check If Two Binary Trees Are the Same
dsaMay 16, 2025

How to Check If Two Binary Trees Are the Same

In this blog, we explore the classic Same Tree problem, where we determine whether two binary trees are structurally identical and have the same node values. We'll break down the problem, build an intuitive understanding, and implement an elegant recursive solution.

magesh
magesh
Depth of the Tree
dsaMay 15, 2025

Depth of the Tree

This blog explains how to determine the maximum depth of a binary tree, covering both recursive and iterative approaches with clear examples. Ideal for coding interview prep or strengthening your data structure fundamentals.

magesh
magesh