All Posts

Leetcode 1888: Minimum Number of Flips to Make the Binary String Alternating

You are given a binary string s consisting of ‘0’s and ‘1’s. You can perform two operations on the string:

  1. Type-1: Move the first character of the string to the end.
  2. Type-2: Flip the value of any character in the string (‘0’ becomes ‘1’ and ‘1’ becomes ‘0’). The goal is to make the string alternating, i.e., no two adjacent characters should be the same. You need to find the minimum number of type-2 operations required to make the string alternating.

Leetcode 1899: Merge Triplets to Form Target Triplet

Given a list of triplets and a target triplet, determine if it is possible to update the triplets through a series of operations to match the target.

Leetcode 1903: Largest Odd Number in String

You are given a string num, which represents a large integer. Your task is to find the largest odd integer that can be formed from any non-empty substring of num. If no odd integer exists, return an empty string.

Leetcode 1921: Eliminate Maximum Number of Monsters

You are defending your city from a group of n monsters. You are given two arrays dist and speed, where dist[i] is the initial distance of the ith monster from the city, and speed[i] is the speed of the ith monster in kilometers per minute. Your weapon takes one minute to charge and can eliminate one monster once fully charged. The game ends if any monster reaches the city before your weapon is ready. Return the maximum number of monsters you can eliminate or n if all monsters can be eliminated before they reach the city.

Leetcode 1936: Add Minimum Number of Rungs

You are at the bottom of a ladder with several rungs already placed. The distance between consecutive rungs should not exceed a given value ‘dist’. If the gap between any two rungs exceeds ‘dist’, you can insert additional rungs to make the ladder climbable. Return the minimum number of rungs that need to be added.

Leetcode 1962: Remove Stones to Minimize the Total

You are given an array of integers piles, where each element represents the number of stones in a pile, and an integer k. You need to perform the following operation exactly k times: Choose any pile, and remove floor(piles[i] / 2) stones from it. You can apply the operation to the same pile multiple times. The goal is to minimize the total number of stones left in all piles after performing the operation k times.