All Posts

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 2784: Check if Array is Good

Determine if an integer array nums is a permutation of a special array base[n], defined as [1, 2, …, n - 1, n, n], where 1 to n-1 appear once and n appears twice.

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 2788: Split Strings by Separator

You are given an array ‘words’ of strings and a character ‘separator’. Your task is to split each string in ‘words’ by the separator. After the split, return an array of strings containing the new substrings, excluding any empty strings.

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 2798: Number of Employees Who Met the Target

You are given an array ‘hours’ where each element represents the number of hours an employee has worked at the company. The company requires each employee to work for at least ’target’ hours. Your task is to return the number of employees who worked at least ’target’ hours.