原创 LeetCode 257 Binary Tree Paths

題目: Given a binary tree, return all root-to-leaf paths. For example, given the following binary tree: 1 / \

原创 LeetCode 543 Diameter of Binary Tree

題目: Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is

原创 LeetCode 235 Lowest Common Ancestor of a Binary Search Tree

題目: Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According

原创 LeetCode 350 Intersection of Two Arrays II

題目: Given two arrays, write a function to compute their intersection. Example: Given nums1 = [1, 2, 2, 1], nums2 = [

原创 LeetCode 100 Same Tree

題目: Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal

原创 LeetCode 21 Merge Two Sorted Lists

題目: Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nod

原创 LeetCode 108 Convert Sorted Array to Binary Search Tree

題目: Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 題目鏈接 題意: 給一個排好序的數

原创 LeetCode 572 Subtree of Another Tree

題目: Given two non-empty binary trees s and t, check whether tree t has exactly the same structure and node values wit

原创 LeetCode 447 Number of Boomerangs

題目: Given n points in the plane that are all pairwise distinct, a "boomerang" is a tuple of points (i, j, k) such th

原创 LeetCode 345 Reverse Vowels of a String

題目: Write a function that takes a string as input and reverse only the vowels of a string. Example 1: Given s = "hel

原创 LeetCode 107 Binary Tree Level Order Traversal II

題目: Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, le

原创 LeetCode 437 Path Sum III

題目: You are given a binary tree in which each node contains an integer value. Find the number of paths that sum to a

原创 LeetCode 643 Maximum Average Subarray I

題目: Given an array consisting of n integers, find the contiguous subarray of given length k that has the maximum ave

原创 LeetCode 367 Valid Perfect Square

題目: Given a positive integer num, write a function which returns True if num is a perfect square else False. Note: D

原创 LeetCode 118 Pascal's Triangle

題目: Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5, Return [ [1