https://leetcode.com/problems/sentence-screen-fitting Solution Time Complexity: O(rows * cols) Space Complexity: O(1) (The input and output generally do not count towards the space complexity.) class ...
https://leetcode.com/problems/group-shifted-strings Solution Time Complexity: O(len(strings)) Space Complexity: O(1) (The input and output generally do not count towards the space complexity.) class S ...
https://leetcode.com/problems/number-of-islands-ii Solution Time Complexity: O(len(positions)) Space Complexity: O(len(positions)) (The input and output generally do not count towards the space comple ...
https://leetcode.com/problems/valid-number Solution Time Complexity: O(len(s)) Space Complexity: O(1) (The input and output generally do not count towards the space complexity.) class Solution: def is ...
https://leetcode.com/problems/asteroid-collision Solution Time Complexity: O(len(asteroids)) Space Complexity: O(len(asteroids)) (The input and output generally do not count towards the space complexi ...
\begin{align} & Diagnal & := \ & matrix[i][i] & \text{ for } i = 0, 1, …, n \\ & Anti-diagnal & := \ & matrix[i][n – i] & \text{ for } i = 0, 1, …, n ...
https://leetcode.com/problems/spiral-matrix Solution Time Complexity: O(len(matrix) * len(matrix[0])) Space Complexity: O(len(matrix) * len(matrix[0])) (The input and output generally do not count tow ...
\begin{align} \mathop{argmax \ }_{x \in S}{f(x)}:=\{ x \in S:f(s) \leq f(x), \ \forall s \in S \} \\ \mathop{argmin \ }_{x \in S}{f(x)}:=\{ x \in S:f(s) \geq f(x), \ \forall s \in S \} \end{align} Re ...
https://leetcode.com/problems/non-overlapping-intervals First Solution Time Complexity: O(len(intervals)) Space Complexity: O(len(intervals)) (The input and output generally do not count towards the s ...
any(iterable): Return True if any element of an iterable is True all(iterable): Return True if all element of an iterable is True 範例 Leetcode # 1275. Find Winner on a Tic Tac Toe Game