[LeetCode] Maximize Consecutive Elements in an Array After Modification

3041. Maximize Consecutive Elements in an Array After Modification

You are given a 0-indexed array nums consisting of positive integers.

Initially, you can increase the value of any element in the array by at most 1.

After that, you need to select one or more elements from the final array such that those elements are consecutive when sorted in increasing order. For example, the elements [3, 4, 5] are consecutive while [3, 4, 6] and [1, 1, 2, 3] are not.

Return the maximum number of elements that you can select.

Read more
[LeetCode] Maximum Number of Operations With the Same Score II

3040. Maximum Number of Operations With the Same Score II

Given an array of integers called nums, you can perform any of the following operation while nums contains at least 2 elements:

  • Choose the first two elements of nums and delete them.
  • Choose the last two elements of nums and delete them.
  • Choose the first and the last elements of nums and delete them.

The score of the operation is the sum of the deleted elements.

Your task is to find the maximum number of operations that can be performed, such that all operations have the same score.

Return the maximum number of operations possible that satisfy the condition mentioned above.

Read more
[LeetCode] Apply Operations to Make String Empty

3039. Apply Operations to Make String Empty

You are given a string s.

Consider performing the following operation until s becomes empty:

  • For every alphabet character from 'a' to 'z', remove the first occurrence of that character in s (if it exists).

Return the value of the string s right before applying the last operation.

Read more
[LeetCode] Maximum Number of Operations With the Same Score I

3038. Maximum Number of Operations With the Same Score I

Given an array of integers called nums, you can perform the following operation while nums contains at least 2 elements:

  • Choose the first two elements of nums and delete them.

The score of the operation is the sum of the deleted elements.

Your task is to find the maximum number of operations that can be performed, such that all operations have the same score.

Return the maximum number of operations possible that satisfy the condition mentioned above.

Read more
[Hacker Rank] Plus MinusRead more
[Hacker Rank] Diagonal DifferenceRead more
[Hacker Rank] A Very Big SumRead more
[Hacker Rank] Compare the TripletsRead more
[Hacker Rank] Simple Array SumRead more
[AtCoder] E - Set MealRead more