Problem https://leetcode.com/problems/target-sum First Try [Time Limit Exceeded 124 / 140 testcases passed] Time Complexity: O(2 ** len(nums)) Space Complexity: O(2 ** len(nums)) (The input and outpu ...
Problem https://leetcode.com/problems/find-largest-value-in-each-tree-row Solution: BFS Time Complexity: O(len(tree)) Space Complexity: O(log(len(tree))) (The input and output generally do not count t ...
Problem https://leetcode.com/problems/find-building-where-alice-and-bob-can-meet Given a, b If a == b, let k = a = b If heights[max(a, b)] > heights[min(a, b)] ⇒ ans = max(a, b) K = set([k for k in ...
親孝—行って何?って考—える でもそれを考—えようとすることがもう 親孝—行なのかもしれない 子供の頃 たまに家族で 外食 いつも頼んでいたのは チキンライス 豪華なもの頼めば二度とつれてきては もらえ—な—いよう—な気—がして 親に気を遣って いたあんな気持ち 今の子供に 理解—できるかな—? 今日は—クリスマス 街はにぎやか お祭り騒ぎ— 七面—鳥は やっぱり照れる— 俺は まだまだチキンライ ...
Problem https://leetcode.com/problems/reverse-odd-levels-of-binary-tree Solution Time Complexity: O(len(tree)) Space Complexity: O(len(tree)) (The input and output generally do not count towards the s ...
Problem https://leetcode.com/problems/minimum-number-of-moves-to-seat-everyone Solution Time Complexity: O(len(seats) * log(len(seats))) Space Complexity: O(len(seats)) (The input and output generally ...
Problem https://leetcode.com/problems/max-chunks-to-make-sorted 把 arr 分成數個 chunk, [sorted(chunk) for chunk in chunks] == sorted(arr) Solution: PrefixMax and SuffixMin Arrays prefix := arr[0 : i] suffi ...
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 ...