All Posts

Leetcode 1704: Determine if String Halves Are Alike

You are given a string ’s’ of even length. Split the string into two equal halves, where the first half is ‘a’ and the second half is ‘b’.

Two strings are considered alike if they contain the same number of vowels (a, e, i, o, u, A, E, I, O, U). Return ’true’ if ‘a’ and ‘b’ are alike, otherwise return ‘false’.

Leetcode 1717: Maximum Score From Removing Substrings

You are given a string s and two integers x and y. You can perform two types of operations any number of times:

  1. Remove the substring “ab” and gain x points.
  2. Remove the substring “ba” and gain y points.

Each time a substring is removed, the characters are deleted from the string, and the corresponding points are added to your total score. Your task is to maximize the total score after applying these operations any number of times.

Leetcode 1736: Latest Time by Replacing Hidden Digits

You are given a time string in the format hh:mm, where some digits may be missing and represented by a question mark (?). Your task is to replace the ? with digits to form the latest valid time in the 24-hour format, which is between 00:00 and 23:59.

Leetcode 1737: Change Minimum Characters to Satisfy One of Three Conditions

You are given two strings, a and b, consisting of lowercase letters. In one operation, you can change any character in either string to any lowercase letter. Your goal is to perform the minimum number of operations to satisfy one of the following three conditions:

  1. Every character in string a is strictly less than every character in string b alphabetically.
  2. Every character in string b is strictly less than every character in string a alphabetically.
  3. Both a and b consist of only one distinct character.

Return the minimum number of operations needed to achieve one of these conditions.

Leetcode 1750: Minimum Length of String After Deleting Similar Ends

You are given a string s consisting of only the characters ‘a’, ‘b’, and ‘c’. Your task is to repeatedly perform the following operation any number of times:

  1. Pick a non-empty prefix from the string where all characters are equal.
  2. Pick a non-empty suffix from the string where all characters are equal.
  3. The prefix and suffix should not intersect, and the characters in both should be the same.
  4. Remove the prefix and suffix.

Your goal is to find the minimum length of the string after performing the operation any number of times.

Leetcode 1754: Largest Merge Of Two Strings

You are given two strings, word1 and word2. You need to construct a string merge by choosing characters from both strings. At each step, you can either append the first character of word1 to merge (if word1 is non-empty) or append the first character of word2 to merge (if word2 is non-empty). The goal is to form the lexicographically largest string possible from these choices.