マガジンのカバー画像

競技プログラミング

145
運営しているクリエイター

#帰りがけ法

ほぼ日刊競プロ leetcode 145. Binary Tree Postorder Traversal

ほぼ日刊競プロ leetcode 145. Binary Tree Postorder Traversal

145. Binary Tree Postorder Traversal
Given the root of a binary tree, return the postorder traversal of its nodes' values.

二分木が与えられるので,値を帰りがけ法で探索し値を返せ

考えた事帰りがけ方のなので以下のように探索する必要がある.

根のノードが最後に来るように探索

もっとみる