All Posts

Leetcode 2771: Longest Non-decreasing Subarray From Two Arrays

You are given two integer arrays, nums1 and nums2, both of the same length n. Your task is to construct a new array nums3 such that each element in nums3 is either taken from nums1 or nums2 at the same index. The goal is to maximize the length of the longest contiguous non-decreasing subarray in nums3.

Leetcode 2772: Apply Operations to Make All Array Elements Equal to Zero

You are given a 0-indexed integer array nums and a positive integer k. You can repeatedly select a contiguous subarray of size k and decrease all its elements by 1. Determine if it is possible to make all elements in nums equal to 0 using this operation.

Leetcode 2780: Minimum Index of a Valid Split

Given a 0-indexed integer array nums of length n, an element x in nums is called dominant if freq(x) * 2 > n, where freq(x) is the number of occurrences of x in nums. It is guaranteed that nums contains exactly one dominant element. You can split nums into two non-empty subarrays at an index i such that the dominant element of the entire array is also the dominant element of both subarrays. Find the minimum index i where this condition holds, or return -1 if no such index exists.

Leetcode 2785: Sort Vowels in a String

You are given a string s. The task is to permute s such that all consonants remain in their original places, and the vowels are sorted in the nondecreasing order of their ASCII values.

Leetcode 2786: Visit Array Positions to Maximize Score

You are given an integer array ’nums’ and a positive integer ‘x’. Starting at index 0, you can move to any position j (where i < j). For each position i that you visit, you get a score of nums[i]. If the parities of nums[i] and nums[j] differ, you lose a score of ‘x’. Your goal is to find the maximum score you can accumulate by visiting positions in the array.

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.