Tag: LeetCode
-
LeetCode: 1071 Greatest Common Divisor of Strings
•
For two strings s1 and s2, we say "s1 divides s2" if and only if s2 is formed by concatenating one or more copies of s1. Given two strings str1 and str2, return the largest string x such that x divides both str1 and str2. Example: Input: str1 = "ABCABC",…
-
LeetCode: 1768 Merge Strings Alternately
•
You are given two strings word1 and word2. Merge the strings by adding letters in alternating order, starting with word1. If a string is longer than the other, append the additional letters onto the end of the merged string. Example: Input: word1 = "abc", word2 = "pqr" Output: "apbqcr" Input:…
-
LeetCode: The Difference between LeetCode 104 and LeetCode 124
•
Problem Statement: 104 Maximum Depth of Binary Tree 104 Maximum Depth of Binary Tree: Given the root of a binary tree, return its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. 问题陈述: 104 二叉树的最大深度…
-
LeetCode: 104 Maximum Depth of Binary Tree
•
Problem Statement Given the root of a binary tree, return its maximum depth. A binary tree’s maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. Example: Input: root = [3,9,20,null,null,15,7] Output: 3 问题 给定一个二叉树的根节点,返回其最大深度。 二叉树的最大深度是从根节点到最远叶节点的最长路径上的节点数量。 示例: 输入: root…
-
LeetCode: 124 Binary Tree Maximum Path Sum
•
Problem Statement Given a non-empty binary tree, find the maximum path sum. For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connections. The path must contain at least one node and does not need…