アルゴリズム

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】202. Happy Number 解答・解説【Python】

問題 原文 Write an algorithm to determine if a number n is happy. A happy number is a number defined by the following...
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】300. Longest Increasing Subsequence 解答・解説【Python】

問題 原文 Given an integer array nums, return the length of the longest strictly increasing  subsequence . ...
Python

【LeetCode】413. Arithmetic Slices 解答・解説【Python】

問題 原文 An integer array is called arithmetic if it consists of at least three elements and if the difference between ...
Python

【LeetCode】62. Unique Paths 解答・解説【Python】

問題 原文 There is a robot on an m x n grid. The robot is initially located at the top-left corner (i.e., grid). The rob...
LeetCode

【LeetCode】17. Letter Combinations of a Phone Number 解答・解説【Python】

問題 原文 Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number c...
LeetCode

【LeetCode】40. Combination Sum II 解答・解説【Python】

問題 原文 Given a collection of candidate numbers (candidates) and a target number (target), find all unique combination...
LeetCode

【LeetCode】200. Number of Islands 解答・解説【Python】

問題 原文 Given an m x n 2D binary grid grid which represents a map of '1's (land) and '0's (water), return the numb...