原创 LeetCode--- Path Sum III、Delete Node in a BST、Find Mode in Binary Search Tree

437. Path Sum III You are given a binary tree in which each node contains an integer value. Find the number of paths th

原创 1到n!的和

sum = 0 shu = int(input("請輸入所求的一個數階乘的累加和: ")) for i in range(1, shu+1): s = 1 for j in range(2, i+1):

原创 LeetCode--- Diameter of Binary Tree、Maximum Depth of N-ary Tree、Average of Levels in Binary Tree

543. Diameter of Binary Tree Given a binary tree, you need to compute the length of the diameter of the tree. The diame

原创 LeetCode---Maximum Binary Tree、Second Minimum Node In a Binary Tree、Search in a Binary Search Tree

654. Maximum Binary Tree Given an integer array with no duplicates. A maximum tree building on this array is defined as

原创 LeetCode---N-ary Tree Preorder Traversal、N-ary Tree Postorder Traversal、Merge Two Binary Trees

589. N-ary Tree Preorder Traversal Given an n-ary tree, return the preorder traversal of its nodes' values. For example

原创 LeetCode---Arithmetic Slices、Partition Equal Subset Sum

413. Arithmetic Slices A sequence of number is called arithmetic if it consists of at least three elements and if the d

原创 LeetCode--- Maximum Subarray、Unique Paths、Unique Paths II、Minimum Path Sum、Climbing Stairs

53. Maximum Subarray Given an integer array nums, find the contiguous subarray (containing at least one number) which h

原创 LeetCode---Jump Game、Jump Game II、Gas Station、Candy、Wiggle Subsequence

55. Jump Game Given an array of non-negative integers, you are initially positioned at the first index of the array. Ea

原创 LeetCode---Triangle、House Robber、House Robber II

120. Triangle Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent number

原创 LeetCode---Perfect Squares、Longest Increasing Subsequence

279. Perfect Squares Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9,

原创 LeetCode---Sum Root to Leaf Numbers、Binary Tree Preorder Traversal、Binary Tree Postorder Traversal

129. Sum Root to Leaf Numbers Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represe

原创 LeetCode--- Sum of Left Leaves、N-ary Tree Level Order Traversal

404. Sum of Left Leaves Find the sum of all left leaves in a given binary tree. Example: 3 / \ 9 20 / \

原创 LeetCode---Binary Gap、Self Dividing Numbers、Reach a Number、Rectangle Overlap

868. Binary Gap Given a positive integer N, find and return the longest distance between two consecutive 1's in the bin

原创 LeetCode---Intersection of Two Arrays、 II、Sort Colors、Largest Perimeter Triangle

349. Intersection of Two Arrays Given two arrays, write a function to compute their intersection. Example 1: Input: nu

原创 LeetCode--Arranging Coins

441. Arranging Coins You have a total of n coins that you want to form in a staircase shape, where every k-th row must