Linked List

因為 Python 多重賦值 (Multiple Assignment) 時的計算順序導致的錯誤 Leetcode # 2. Add Two Numbers ⭐️ Leetcode # 206. Reverse Linked List 追加 node 適切的方式 使用 pre Leetcode # 206. Reverse Linked List 在迴圈繼續時才追加 Leetcode # 2. A ...

         続きを読む

Leetcode # 1056. Confusing Number

https://leetcode.com/problems/confusing-number Solution 問題:n 是否顛倒後仍是一組數字並且不等於 n ? Time Complexity: O(log(n)) Space Complexity: O(1) (The input and output generally do not count towards the space compl ...

         続きを読む

Leetcode # 859. Buddy Strings

https://leetcode.com/problems/buddy-strings Solution 交換兩個 character 後 s 和 gaol 會一樣 ⇒ 回傳 True s 和 goal 只有在 i, j 的兩個 character 不一樣 (s[i] != goal[i] and s[j] != goal [j]), 且 s[i] = goal[j], s[j] = goal[i ...

         続きを読む
1 ... 26 ... 52
Bitnami