All Posts

Leetcode 2712: Minimum Cost to Make All Characters Equal

You are given a binary string s of length n. You can perform two types of operations: (1) Flip all characters from index 0 to i (inclusive), with a cost of i + 1. (2) Flip all characters from index i to n - 1 (inclusive), with a cost of n - i. The goal is to return the minimum cost required to make all the characters in the string equal (either all 0s or all 1s).

Leetcode 2716: Minimize String Length

You are given a string s. You can perform two types of operations: (1) Choose an index i and remove the closest occurrence of the character at i to the left of i. (2) Choose an index i and remove the closest occurrence of the character at i to the right of i. Minimize the length of the string s by performing these operations and return the final minimized length.

Leetcode 2730: Find the Longest Semi-Repetitive Substring

You are given a string s consisting of digits from ‘0’ to ‘9’. A string is called semi-repetitive if there is at most one pair of adjacent identical digits. Your task is to return the length of the longest semi-repetitive substring of s.

Leetcode 2734: Lexicographically Smallest String After Substring Operation

You are given a string s consisting of lowercase English letters. You can perform the operation of replacing every letter of a selected non-empty substring with the preceding letter in the alphabet. Your task is to return the lexicographically smallest string possible after performing the operation.

Leetcode 2744: Find Maximum Number of String Pairs

You are given a list of distinct strings words, where each string consists of exactly two lowercase English letters. You are tasked with finding the maximum number of pairs of strings that can be formed where one string is the reverse of the other.

Leetcode 2746: Decremental String Concatenation

You are given an array of distinct strings. Your task is to perform n-1 join operations optimally to minimize the length of the final string.