Greedy from Left Right¶
Table of Contents¶
- 3402. Minimum Operations to Make Columns Strictly Increasing (Easy)
- 3191. Minimum Operations to Make Binary Array Elements Equal to One I (Medium)
- 1827. Minimum Operations to Make the Array Increasing (Easy)
- 2027. Minimum Moves to Convert String (Easy)
- 605. Can Place Flowers (Easy)
- 3111. Minimum Rectangles to Cover Points (Medium)
- 2957. Remove Adjacent Almost-Equal Characters (Medium)
- 3192. Minimum Operations to Make Binary Array Elements Equal to One II (Medium)
- 2789. Largest Element in an Array after Merge Operations (Medium)
- 1529. Minimum Suffix Flips (Medium)
- 1144. Decrease Elements To Make Array Zigzag (Medium)
- 3228. Maximum Number of Operations to Move Ones to the End (Medium)
- 2086. Minimum Number of Food Buckets to Feed the Hamsters (Medium)
- 2571. Minimum Operations to Reduce an Integer to 0 (Medium)
- 2712. Minimum Cost to Make All Characters Equal (Medium)
- 3326. Minimum Division Operations to Make Array Non Decreasing (Medium)
- 1536. Minimum Swaps to Arrange a Binary Grid (Medium)
- 2673. Make Costs of Paths Equal in a Binary Tree (Medium)
- 861. Score After Flipping Matrix (Medium)
- 955. Delete Columns to Make Sorted II (Medium)
- 2366. Minimum Replacements to Sort the Array (Hard)
- 2193. Minimum Number of Moves to Make Palindrome (Hard)
- 2528. Maximize the Minimum Powered City (Hard)
- 3449. Maximize the Minimum Game Score (Hard)
- 2422. Merge Operations to Turn Array Into a Palindrome (Medium) 👑
3402. Minimum Operations to Make Columns Strictly Increasing¶
-
LeetCode | LeetCode CH (Easy)
-
Tags: array, greedy, matrix
3191. Minimum Operations to Make Binary Array Elements Equal to One I¶
-
LeetCode | LeetCode CH (Medium)
-
Tags: array, bit manipulation, queue, sliding window, prefix sum
1827. Minimum Operations to Make the Array Increasing¶
-
LeetCode | LeetCode CH (Easy)
-
Tags: array, greedy
2027. Minimum Moves to Convert String¶
-
LeetCode | LeetCode CH (Easy)
-
Tags: string, greedy
605. Can Place Flowers¶
-
LeetCode | LeetCode CH (Easy)
-
Tags: array, greedy
3111. Minimum Rectangles to Cover Points¶
-
LeetCode | LeetCode CH (Medium)
-
Tags: array, greedy, sorting
2957. Remove Adjacent Almost-Equal Characters¶
-
LeetCode | LeetCode CH (Medium)
-
Tags: string, dynamic programming, greedy
3192. Minimum Operations to Make Binary Array Elements Equal to One II¶
-
LeetCode | LeetCode CH (Medium)
-
Tags: array, dynamic programming, greedy
2789. Largest Element in an Array after Merge Operations¶
-
LeetCode | LeetCode CH (Medium)
-
Tags: array, greedy
1529. Minimum Suffix Flips¶
-
LeetCode | LeetCode CH (Medium)
-
Tags: string, greedy
1144. Decrease Elements To Make Array Zigzag¶
-
LeetCode | LeetCode CH (Medium)
-
Tags: array, greedy
3228. Maximum Number of Operations to Move Ones to the End¶
-
LeetCode | LeetCode CH (Medium)
-
Tags: string, greedy, counting
2086. Minimum Number of Food Buckets to Feed the Hamsters¶
-
LeetCode | LeetCode CH (Medium)
-
Tags: string, dynamic programming, greedy
2571. Minimum Operations to Reduce an Integer to 0¶
-
LeetCode | LeetCode CH (Medium)
-
Tags: dynamic programming, greedy, bit manipulation
2712. Minimum Cost to Make All Characters Equal¶
-
LeetCode | LeetCode CH (Medium)
-
Tags: string, dynamic programming, greedy
def minimumCost(s: str) -> int:
n = len(s)
res = 0
for i in range(1, n):
if s[i - 1] != s[i]:
res += min(i, n - i)
return res
if __name__ == "__main__":
s = "0011"
print(minimumCost(s)) # 2
3326. Minimum Division Operations to Make Array Non Decreasing¶
-
LeetCode | LeetCode CH (Medium)
-
Tags: array, math, greedy, number theory
1536. Minimum Swaps to Arrange a Binary Grid¶
-
LeetCode | LeetCode CH (Medium)
-
Tags: array, greedy, matrix
2673. Make Costs of Paths Equal in a Binary Tree¶
-
LeetCode | LeetCode CH (Medium)
-
Tags: array, dynamic programming, greedy, tree, binary tree
861. Score After Flipping Matrix¶
-
LeetCode | LeetCode CH (Medium)
-
Tags: array, greedy, bit manipulation, matrix
955. Delete Columns to Make Sorted II¶
-
LeetCode | LeetCode CH (Medium)
-
Tags: array, string, greedy
2366. Minimum Replacements to Sort the Array¶
-
LeetCode | LeetCode CH (Hard)
-
Tags: array, math, greedy
2193. Minimum Number of Moves to Make Palindrome¶
-
LeetCode | LeetCode CH (Hard)
-
Tags: two pointers, string, greedy, binary indexed tree
2528. Maximize the Minimum Powered City¶
-
LeetCode | LeetCode CH (Hard)
-
Tags: array, binary search, greedy, queue, sliding window, prefix sum
3449. Maximize the Minimum Game Score¶
-
LeetCode | LeetCode CH (Hard)
-
Tags: array, binary search, greedy
2422. Merge Operations to Turn Array Into a Palindrome¶
-
LeetCode | LeetCode CH (Medium)
-
Tags: array, two pointers, greedy