原创 【貪心】B036_LC_最多可以參加的會議數目(排序 / pq)

一、Problem Given an array of events where events[i] = [startDayi, endDayi]. Every event i starts at startDayi and en

原创 【區間 dp】A005_LC_工作計劃的最低難度(暴搜 / dp)

一、Problem You want to schedule a list of jobs in d days. Jobs are dependent (i.e To work on the i-th job, you have

原创 【數學】C068_LC_日期之間隔幾天(枚舉 / 庫函數)

一、Problem Write a program to count the number of days between two dates. The two dates are given as strings, their

原创 【數組】B061_LC_形成兩個異或相等數組的三元組數目(暴力 / 暴力優化 / 前綴和 / 異或規則)

一、Problem Given an array of integers arr. We want to select three indices i, j and k where (0 <= i < j <= k < arr.l

原创 探望病人時可以說的話!

第一:誇氣色、問飲食。 第二:可以多說些鼓勵的話,給親人更多戰勝病魔的信心。這兒醫療條件不錯,您的病一定會很快好轉的。 文學版: 既來之,則安之,順其自然.積極配合醫生治療 越堅強、知越樂觀、越積極面對,希望就越大! 家常

原创 【數學】B067_LC_最接近的因數(枚舉 / 優化)

一、Problem Given an integer num, find the closest two integers in absolute difference whose product equals num + 1 o

原创 【圖論】B030_LC_收集樹上所有蘋果的最少時間(2 × dfs)

一、Problem 二、Solution 方法一:2 × dfs 第一眼感覺就是 dfs 遍歷樹,而且題目確定是從 0 開始了,如果從指定節點開始那麼題目會難很多,看看思路趴。 對於一個結點 u,我們不能盲目地去遍歷它,只有當

原创 【貪心】A035_LC_多次求和構造目標數組(暴力排序 / 暴力優化 / (未 ac))

一、Problem Given an array of integers target. From a starting array, A consisting of all 1’s, you may perform the fo

原创 【數學】B069_LC_Pow(x, n)(qp 迭代 / 遞歸)

一、Problem Implement pow(x, n), which calculates x raised to the power n (xn). Input: 2.00000, 10 Output: 1024.00000

原创 【圖論】B031_LC_閾值距離內鄰居最少的城市(dfs 錯誤遍歷 / floyd)

一、Problem There are n cities numbered from 0 to n-1. Given the array edges where edges[i] = [fromi, toi, weighti] r

原创 【樹】B030_LC_分裂二叉樹的最大乘積(求子樹和)

一、Problem Input: root = [1,2,3,4,5,6] Output: 110 Explanation: Remove the red edge and get 2 binary trees with sum

原创 【樹】B028_二叉樹的最近公共祖先(需要獲取返回值 / 記錄結點的父節點)

一、Problem Input: root = [3,5,1,6,2,0,8,null,null,7,4], p = 5, q = 1 Output: 3 Explanation: The LCA of nodes 5 and

原创 【樹】B029_LC_刪除給定值的葉子節點(奇怪的後序 / 層序遍歷)

一、Problem Input: root = [1,2,3,2,null,2,4], target = 2 Output: [1,null,3,null,4] Explanation: Leaf nodes in green

原创 【搜索】B054_NK_十面埋伏(Flood Fill(越界?))

一、Problem 6 5 ..... .###. .#.#. .###. ..##. ..... 輸出 .***. *###* *#.#* *###* .*##* ..**. 二、Solution 方法一:Flood Fi

原创 【數組】B059_牛牛的揠苗助長(排序 + 二分)

一、Problem 牛牛有一塊長度大小爲n的菜園,他首先對這塊菜園從1到n進行了編號,每一塊地分別爲1號、2號…n號菜地,然後他往每塊菜地中都種下了一些水稻,一開始,第i塊菜地中的水稻高度均爲a[i]個單位。 然後我們知道水稻的生