@Tōsaka-Rin ka-Rin The way you solved the problem is way more inefficient. You traversed the tree for n times, and made your algorithm of O(n^2), where the original one is a one time traversal solution.

Diameter of Binary Tree

Diameter of Binary Tree