You are given a 0-indexed array nums consisting of n positive integers. The array nums is called alternating if nums[i - 2] == nums[i] and nums[i - 1] != nums[i] for all valid i. In one operation, you can choose an index i and change nums[i] into any positive integer. Your task is to return the minimum number of operations required to make the array alternating.
You are given an array of positive integers representing the number of magic beans in each bag. Your task is to remove some beans (possibly none) from each bag so that the number of beans in each remaining non-empty bag is equal. You need to find the minimum number of beans to remove.
Given an integer num, your task is to determine if it can be expressed as the sum of three consecutive integers. If it can, return these integers as a sorted array. If not, return an empty array.
Given an integer finalSum, split it into a sum of as many unique positive even integers as possible. If such a split is not possible, return an empty array.
You are given the head of a linked list where each segment of the list is separated by nodes with the value 0. Merge the nodes between two consecutive 0 nodes and replace them with a single node whose value is the sum of the nodes in between. The list should not contain any 0 nodes.
Given a string of lowercase letters and an integer limit, construct a new string such that no character appears more than the given limit times consecutively. The new string should be lexicographically largest while satisfying this condition. You can use any subset of characters from the given string.