Problem https://leetcode.com/problems/final-prices-with-a-special-discount-in-a-shop ∀ i in range(prices), If ∃ js = [j for j in range(i + 1, len(prices)) if (j > i and prices[j] <= prices[i])] ...
Problem https://leetcode.com/problems/construct-string-with-repeat-limit Solution Time Complexity: O(len(s)) Space Complexity: O(1) (The input and output generally do not count towards the space compl ...
Problem https://leetcode.com/problems/final-array-state-after-k-multiplication-operations-i Solution Time Complexity: O(len(nums)) + k * log(len(num))) Space Complexity: O(len(nums)) (The input and ou ...
Problem https://leetcode.com/problems/maximum-average-pass-ratio Solution: Priority Queue Priority Queue 裡面要放甚麼? the pass ratios the number of total students the gains in the pass ratio Code Time Comp ...
for i, (a, b, c) in enumerate(list_x)
Problem https://leetcode.com/problems/find-score-of-an-array-after-marking-all-elements Solution: Sorting Sort by Multiple Keys Time Complexity: O(len(nums) * log(len(nums))) Space Complexity: O(len(n ...
Problem https://leetcode.com/problems/take-gifts-from-the-richest-pile Solution Time Complexity: O(len(gifts)) Space Complexity: O(len(gifts)) (The input and output generally do not count towards the ...
Function def function(): ... Method class 底下有 method 和 attribute (屬性), 即 method 便是 class 的 member function (成員函式) class c: def method(): ...
Problem https://leetcode.com/problems/maximum-beauty-of-an-array-after-applying-operation Solution n ∈ nums, you can replace it with any integer from the range [n – k, n + k] ⇒ plus 1 (+1) from ...
Problem https://leetcode.com/problems/find-longest-special-substring-that-occurs-thrice-i Solution / First Try 第 5 行的s + "*"是為了能在結尾時再做一次判斷 aaaaa代表包含 1 個aaaaa, 2 個aaaa, 3 個aaa, 4 個aa, 5 個a Time Complex ...