All Posts

Leetcode 2645: Minimum Additions to Make Valid String

Given a string ‘word’ consisting of letters ‘a’, ‘b’, and ‘c’, you can insert letters ‘a’, ‘b’, or ‘c’ anywhere and as many times as needed. Your task is to determine the minimum number of insertions required to transform ‘word’ into a valid string. A string is considered valid if it can be formed by repeatedly concatenating the string ‘abc’.

Leetcode 2678: Number of Senior Citizens

You are given a perfect binary tree with n nodes, where each node has a cost associated with it. The tree is numbered from 1 to n, with node 1 as the root. For each node i, its left child is 2*i and its right child is 2*i + 1. You are allowed to increment the cost of any node by 1 any number of times. Your task is to return the minimum number of increments required to make the total cost of the path from the root to each leaf node equal.

Leetcode 2696: Minimum String Length After Removing Substrings

You are given a string s consisting of only uppercase English letters. You can repeatedly remove any occurrence of the substrings ‘AB’ or ‘CD’ from s. Each operation removes one of these substrings and shortens the string. After performing the operations, return the minimum possible length of the resulting string. Note that removing substrings can create new occurrences of ‘AB’ or ‘CD’, which can be removed in further operations.

Leetcode 2697: Lexicographically Smallest Palindrome

You are given a string s consisting of lowercase English letters. You can perform operations on this string where in each operation, you replace a character in s with another lowercase English letter. The goal is to make s a palindrome using the minimum number of operations possible. If there are multiple ways to achieve the same minimum number of operations, return the lexicographically smallest palindrome string.

Leetcode 2707: Extra Characters in a String

You are given a string and a list of words. Your task is to break the string into one or more non-overlapping substrings such that each substring is a word from the given list. However, some characters of the string may not be used in any substring. Your goal is to minimize the number of unused characters.

Leetcode 2710: Remove Trailing Zeros From a String

Given a positive integer represented as a string, your task is to return the same integer but with all trailing zeros removed. The result should also be returned as a string.