討論串[閒聊] 每日LeetCode
共 719 篇文章
內容預覽:
104. Maximum Depth of Binary Tree. 找出一棵二元樹的max depth. C# code. public class Solution {. public int MaxDepth(TreeNode node) {. if (node == null) return
(還有60個字)
內容預覽:
989. Add to Array-Form of Integer. 給一個十進位的大數陣列 num 跟一個 integer k,. 求兩者相加後的結果。. Example 1:. Input: num = [1, 2, 0, 0], k = 34. Output: [1, 2, 3, 4]. Ex
(還有1366個字)
內容預覽:
67. Add Binary. 給定兩個二進位字串 a, b,. 求 a+b 的後的二進位字串。. Example 1:. Input: a = "11", b = "1". Output: "100". Explanation: a = 3, b = 1, 相加後為 4 (100). Exampl
(還有757個字)
內容預覽:
1523. Count Odd Numbers in an Interval Range. 給定 low 跟 high 這個範圍,. 求 [low, high] 這個區間中有多少個奇數。. Example 1:. Input: low = 3, high = 7. Output: 3. Explan
(還有735個字)
內容預覽:
思路:. 1.這題關鍵點是必須注意到一個規律:所有的車子都是從最外面往中心點(0號城市)移動. 若你要從中心點往外移動的話因為要往返的關係所以會消耗兩倍的油,必不是最佳解。. 2.在一的前提之下,所有最外邊的城市都往中心點方向移動,例如:下列紅色的點往上移. 0. |. 1. / | \. 2 3
(還有1127個字)