The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. DFS: int maxDepth(TreeNode *root) { // Start typing your C/C++ solution below // DO NOT write in
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
Total Accepted: 63668 Total Submissions: 141121 My Submissions Question Solution Given a binary tree, find 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. 我的解决方案: /** * Definition for a binary tree...
代码语言:javascript 代码运行次数:0 运行 AI代码解释 /** 作者:li-zhui-zhui 链接:https://leetcode-cn.com/problems/container-with-most-water/solution/11-sheng-zui-duo-shui-de-rong-qi-by-li-zhui-zhui/ * @param {number[]} height * @return {number} */ var maxArea = function (height) {...
myAtoi(s: String): Int = { import scala.util.{Failure, Success, Try} val numberPatt...
Happy Number (medium) Middle of the LinkedList (easy) 4. Pattern: Merge Intervals,区间合并类型 区间合并模式是一个用来处理有区间重叠的很高效的技术。在设计到区间的很多问题中,通常咱们需要要么判断是否有重叠,要么合并区间,如果他们重叠的话。这个模式是这么起作用的: 给两个区间,一个是a,另外一个是b。
434 Number of Segments in a String 36.7% Easy 435 Non-overlapping Intervals 41.4% Medium 436 Find Right Interval 42.4% Medium 437 Path Sum III 42.1% Easy 438 Find All Anagrams in a String 36.7% Easy 440 K-th Smallest in Lexicographical Order 26.3% Hard 441 Arranging Coins 37.6% Easy 442...
Largest Number 187. Repeated DNA Sequences 190. Reverse Bits 191. Number of 1 Bits 198. House Robber 199. Binary Tree Right Side View 200. Number of Islands 201. Bitwise AND of Numbers Range 202. Happy Number 203. Remove Linked List Elements 204. Count Primes 205. Isomorphic Strings 206...
:question: My LeetCode solutions. Contribute to MrHuxu/leetcode development by creating an account on GitHub.
LeetCode 1353 Maximum Number of Events That Can Be Attended Medium Since there's no priority order among these events (i.e. any event can be selected in a specific day), we can solve this question by always selecting the most recently due event. We can first sort the original array by...