All Posts

Leetcode 2024: Maximize the Confusion of an Exam

You are given a string answerKey where each character represents a question’s answer (either ‘T’ for True or ‘F’ for False), and an integer k. You are allowed to change at most k answers. Your task is to find the maximum number of consecutive ‘T’s or ‘F’s in the string after performing at most k changes.

Leetcode 2055: Plates Between Candles

You are tasked with processing a string of plates (’*’) and candles (’|’) arranged on a table. For a set of queries, you must determine the number of plates that are enclosed by candles within specified substrings of the string.

Leetcode 2100: Find Good Days to Rob the Bank

You are planning a bank robbery with a gang of thieves. You are given a list, ‘security’, where each element represents the number of guards present on duty each day. You are also given an integer, ’time’, which represents the number of days before and after the current day that must have specific guard arrangements for it to be a good day for the robbery. A good day to rob the bank is defined as:

  1. There must be at least ’time’ days before and after the current day.
  2. The number of guards on the days before the current day must be non-increasing.
  3. The number of guards on the days after the current day must be non-decreasing. Return a list of all the days that are good days to rob the bank.

Leetcode 2121: Intervals Between Identical Elements

You are given an array of integers. Your task is to calculate the sum of absolute differences between the index of each element and the indices of all other occurrences of the same element. For each element in the array, return the sum of intervals to all its identical elements in the array.

Leetcode 2145: Count the Hidden Sequences

You are given an array representing the differences between each pair of consecutive integers of a hidden sequence. You are also given two integers, lower and upper, which define an inclusive range that the elements of the hidden sequence can take. Your task is to determine the number of possible hidden sequences that fit the given differences and lie within the specified range.

Leetcode 2171: Removing Minimum Number of Magic Beans

You are given an array of positive integers representing the number of magic beans in each bag. Your task is to remove some beans (possibly none) from each bag so that the number of beans in each remaining non-empty bag is equal. You need to find the minimum number of beans to remove.