第一次想這題時方向不太對 public List spiralOrderint matrix //indexm 走0n.length-1格 //indexm1 走 最後n-1 //indexm2 走 n-1 0 //回到indexm1走 0n-2 else ifi==m-1//最後一列 els
- 1月 31 週一 202209:59
【LeetCode】Spiral Matrix
- 1月 31 週一 202209:09
【LeetCode】Pow(x, n)
第一個想法,暴力破解 public double myPowdouble x, int n int round= Math.absn;//絕對值 i; else 正確簡潔的作法,使用遞迴: public double myPowdouble x, int n
- 1月 30 週日 202207:15
【LeetCode】筆記-Wildcard Matching
public boolean isMatchString str, String pattern // advancing both pointers s; p; // found, only advancing pattern pointer else if p p; // last pa
- 1月 29 週六 202208:32
【LeetCode】Trapping Rain Water
- 1月 27 週四 202205:11
【LeetCode】筆記-Merge k Sorted Lists
解答中的分治法 Divide-and-conquer algorithm public static ListNode mergeKListsListNode lists public static ListNode partionListNode lists,int s,int e int q=
- 1月 27 週四 202200:53
【LeetCode】筆記-Generate Parentheses
一個必定有另一個 所以n=1時21, n=2時22,n=3時23, 總結就是2n個符號 不可能有先開始,所以驗證時 balance 只會為正或為 0, n=1, n=2, , n=3, ,,,, ---------------------------------- public List gen
- 1月 26 週三 202207:56
【LeetCode】筆記Valid Parentheses
這題用stack真是太妙了 string 則 stack放 ,下一個如果是 就符合剛放進stack的 public boolean isValidString s else if c == else if c == else if stack.isEmpty stack.pop != c
- 1月 26 週三 202207:11
【LeetCode】筆記Letter Combinations of a Phone Number
未按任何號碼時,字串回傳空 按一個時回傳該數字對應的字串 多個時則遞迴 public List letterHelperString digit,HashMap map public List letterCombinationsString digits
- 1月 25 週二 202208:08
【LeetCode】筆記Regular Expression Matching
我會先思考題意 .表示一個a-z, 表示0或多個 a-z s=aa, p=a 時會等於false, 因為既沒有.也沒有就要完全符合 s=aa, p=a.時會等於true, 因為s=aa的第二個字符符合任意一個字母 s=aa, p=a時會等於true, 因為s=aa的第二個字符符合任意多個字母 所以p
- 1月 24 週一 202206:22
【LeetCode】筆記-Median of Two Sorted Arrays
朋友很力挺繼續練習程式邏輯,讓我加入讀書會! 看到Google 2020年考古題,網路上很多好人們分享的 決定慢慢來破解它 第一個想法是 A B 排序 取中位數 但顯然這不符合題意 Ologmn 正解:點擊此處 時間複雜度複習:初學者學演算法-談什麼是演算法和時間複雜度 ----------

