Skip to content

Greedy from Left Right

Table of Contents

3402. Minimum Operations to Make Columns Strictly Increasing

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

2027. Minimum Moves to Convert String

605. Can Place Flowers

3111. Minimum Rectangles to Cover Points

2957. Remove Adjacent Almost-Equal Characters

3192. Minimum Operations to Make Binary Array Elements Equal to One II

2789. Largest Element in an Array after Merge Operations

1529. Minimum Suffix Flips

1144. Decrease Elements To Make Array Zigzag

3228. Maximum Number of Operations to Move Ones to the End

2086. Minimum Number of Food Buckets to Feed the Hamsters

2571. Minimum Operations to Reduce an Integer to 0

2712. Minimum Cost to Make All Characters Equal

2712. Minimum Cost to Make All Characters Equal - Python Solution
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

1536. Minimum Swaps to Arrange a Binary Grid

2673. Make Costs of Paths Equal in a Binary Tree

861. Score After Flipping Matrix

955. Delete Columns to Make Sorted II

2366. Minimum Replacements to Sort the Array

2193. Minimum Number of Moves to Make Palindrome

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

2422. Merge Operations to Turn Array Into a Palindrome

Comments