All Posts

Leetcode 2708: Maximum Strength of a Group

You are given an integer array representing the scores of students in an exam. Your task is to form a non-empty group of students such that the group’s strength, defined as the product of their scores, is maximized. The goal is to return the maximum possible strength that can be achieved by choosing an optimal group of students.

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 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 2789: Largest Element in an Array after Merge Operations

You are given a 0-indexed array ’nums’ consisting of positive integers. You can repeatedly perform an operation where you choose an index ‘i’ such that ’nums[i] <= nums[i + 1]’, replace ’nums[i + 1]’ with ’nums[i] + nums[i + 1]’, and remove ’nums[i]’. Your task is to determine the largest possible value that can remain in the array after performing any number of operations.

Leetcode 2800: Shortest String That Contains Three Strings

Given three strings ‘a’, ‘b’, and ‘c’, find a string that contains all three of these strings as substrings and has the minimum possible length. If there are multiple such strings, return the lexicographically smallest one.

Leetcode 2811: Check if it is Possible to Split Array

You are given an array nums and an integer m. You need to determine if it’s possible to split the array into n subarrays of size 1, following the rules that each subarray must either have length 1 or have a sum of elements greater than or equal to m.