LeetCode

【LeetCode】119. Pascal’s Triangle II 解答・解説【Python】

問題 原文 Given an integer rowIndex, return the rowIndexth (0-indexed) row of the Pascal's triangle. In Pascal's tria...
LeetCode

【LeetCode】118. Pascal’s Triangle 解答・解説【Python】

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

【LeetCode】112. Path Sum 解答・解説【Python】

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

【LeetCode】 111. Minimum Depth of Binary Tree 解答・解説【Python】

問題 原文 Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path...
LeetCode

【LeetCode】 110. Balanced Binary Tree 解答・解説【Python】

問題 原文 Given a binary tree, determine if it is height-balanced. Example 1: Input: root = Output: tr...
アルゴリズム

データ構造とアルゴリズムの計算量と実装

データ構造とアルゴリズムについて勉強したことを少しずつ書き足していきます。 計算量 ・計算量には時間計算量/空間計算量がある ・時間計算量は処理に必要な時間、空間計算量は処理に必要な記憶容量を指す ・時間計算量を考えるには実...
Rust

【Rust】基本操作

基本操作 変数の設定 定数の設定 ・定数はコード全体で何度も使われる値を設定できる ・型設定が必須 ・大文字のスネークケース SCREAMING_SNAKE_CASEを使用する 配列 ...
LeetCode

【LeetCode】 108. Convert Sorted Array to Binary Search Tree 解答・解説【Python】

問題 原文 Given an integer array nums where the elements are sorted in ascending order, convert it to a height-balanced ...
LeetCode

【LeetCode】 101. Symmetric Tree 解答・解説【Python】

問題 原文 Given the root of a binary tree, check whether it is a mirror of itself (i.e., symmetric around its center). ...
LeetCode

【LeetCode】 100. Same Tree 解答・解説【Python】

問題 原文 Given the roots of two binary trees p and q, write a function to check if they are the same or not. Two bin...