3041. Maximize Consecutive Elements in an Array After Modification
You are given a 0-indexed array
numsconsisting 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.
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 whilenumscontains at least2elements:
- Choose the first two elements of
numsand delete them.- Choose the last two elements of
numsand delete them.- Choose the first and the last elements of
numsand 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.
3039. Apply Operations to Make String Empty
You are given a string
s.Consider performing the following operation until
sbecomes empty:
- For every alphabet character from
'a'to'z', remove the first occurrence of that character ins(if it exists).Return the value of the string
sright before applying the last operation.
3038. Maximum Number of Operations With the Same Score I
Given an array of integers called
nums, you can perform the following operation whilenumscontains at least2elements:
- Choose the first two elements of
numsand 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.