幅優先探索

Atcoder

【ABC325】Atcoder Beginner Contest325 A・B・C問題 解答・解説【Python】

A問題 解答 B問題 方針 0時~23時までを全探索 各時間から8時間差までの地域の参加可能人数を加えていく その合計の最大値を返す LeetCodeにも類題がある。考え方は...
LeetCode

【LeetCode】700. Search in a Binary Search Tree 解答・解説【Python】

はじめに LeetCodeの問題を解答します。 なるべく、問題の和訳と詳細なコメントを書いています。 余裕があれば、複数のアプローチの解答と、実際の面接を想定して英語での解法やコメントを書いています。 これま...
LeetCode

【LeetCode】 872. Leaf-Similar Trees 解答・解説【Python】

はじめに LeetCodeの問題を解答します。 なるべく、問題の和訳と詳細なコメントを書いています。 余裕があれば、複数のアプローチの解答と、実際の面接を想定して英語での解法やコメントを書いています。 様々な...
LeetCode

【LeetCode】 102. Binary Tree Level Order Traversal 解答・解説【Python】

はじめに LeetCodeの問題を解答します。 なるべく、問題の和訳と詳細なコメントを書いています。 余裕があれば、複数のアプローチの解答と、実際の面接を想定して英語での解法やコメントを書いています。 ...
LeetCode

【LeetCode】404. Sum of Left Leaves 解答・解説【Python】

問題 原文 Given the root of a binary tree, return the sum of all left leaves. A leaf is a node with no children. A le...
LeetCode

【LeetCode】637. Average of Levels in Binary Tree 解答・解説【Python】

問題 原文 Given the root of a binary tree, return the average value of the nodes on each level in the form of an array. ...
LeetCode

【LeetCode】107. Binary Tree Level Order Traversal II 解答・解説【Python】

問題 原文 Given the root of a binary tree, return the bottom-up level order traversal of its nodes' values. (i.e., from ...
LeetCode

【LeetCode】733. Flood Fill 解答・解説【Python】

学習メモ 自分の言葉で書くことで理解できていない部分をハッキリさせたい。 問題 原文 An image is represented by an m x n integer grid image where image repr...