Problem https://leetcode.com/contest/weekly-contest-365/problems/maximum-value-of-an-ordered-triplet-ii/ return max((nums[i] – nums[j]) * nums[k] for i, j, k ∈ 1, 2, …, n if i < j < ...
Problem https://leetcode.com/contest/weekly-contest-365/problems/maximum-value-of-an-ordered-triplet-i/ Solution 請參考 Leetcode # 2874. Maximum Value of an Ordered Triplet II
Definition Undirected Graph G = (V, E) V : Vertices 頂點 E : Edges 邊 := (u, v) Adjacent Vertexs A vertex u is adjacent to vertex v ⇔ (u, v) ∈ E Directed Graph|Digraph G = (V, A) E : Arcs 邊 := (x, y); x ...
Problem https://leetcode.com/contest/weekly-contest-365/problems/count-visited-nodes-in-a-directed-graph/ Testcases # Input Expected 1 [7,0,7,0,5,3,3,0] [2,3,3,3,5,4,4,2] [3,6,1,0,5,7,4,3] [2,7,8,2, ...
Problem https://leetcode.com/contest/biweekly-contest-114/problems/minimum-number-of-operations-to-make-array-empty/ Testcases # Input Expected 1 [14,12,14,14,12,14,14,12,12,12,12,14,14,12,14,14,14,12 ...
Problem https://leetcode.com/contest/biweekly-contest-114/problems/minimum-operations-to-collect-elements/ The input is generated such that you can collect elements 1, 2, …, k. ⇒ find len(nums) ...
Regular Expression Python: re Functions re.search(pattern, string, flags=0) 尋找string中第一個符合正則表達式 (regular expression) pattern的substring. 沒有則傳回 None. flags: class re.RegexFlag (配對正則表達式的選項, 忽略大小寫 ...
Problem https://leetcode.com/contest/weekly-contest-363/problems/maximum-number-of-alloys/ Solution: Binary Search Time Complexity: O(max((stock[m] + budget // cost[m]) // machine[m] for m in range(n) ...
Problem https://leetcode.com/contest/weekly-contest-363/problems/maximum-element-sum-of-a-complete-subset-of-indices/ complete(set_of_numbers) ← True, if ∀ x, y ∈ set_of_numbers, ∃ z ∈ ℕ s.t. x * y == ...
Problem https://leetcode.com/contest/weekly-contest-363/problems/happy-students/ if i ∈ selected ∧ len(selected) > nums[i] => ith student is happy if i ∉ selected ∧ len(selected) < nums[i] =& ...