All Posts

Leetcode 2580: Count Ways to Group Overlapping Ranges

There are n people standing in a line labeled from 1 to n. The first person starts with a pillow. Every second, the person holding the pillow passes it to the next person in line. Once the pillow reaches the last person in the line, it starts moving back in the opposite direction, passing towards the first person. Given n and time, return the index of the person holding the pillow after time seconds.

Leetcode 2586: Count the Number of Vowel Strings in Range

You are given a 0-indexed integer array nums. You can rearrange the elements of nums to any order (including the given order). Define the prefix sum array of nums as prefix[i] = sum(nums[0] to nums[i]) after rearranging. The score of nums is the number of positive integers in the prefix array. Return the maximum score you can achieve by rearranging the elements of nums.

Leetcode 2587: Rearrange Array to Maximize Prefix Score

You are given a 0-indexed integer array nums. In one operation, you can choose two indices and subtract a power of two from both elements at those indices. A subarray is considered beautiful if you can make all of its elements equal to zero by applying the operation any number of times. Your task is to return the number of beautiful subarrays in nums.

Leetcode 2588: Count the Number of Beautiful Subarrays

You are given a 0-indexed integer array nums. In one operation, you can choose two indices and subtract a power of two from both elements at those indices. A subarray is considered beautiful if you can make all of its elements equal to zero by applying the operation any number of times. Your task is to return the number of beautiful subarrays in nums.

Leetcode 2592: Maximize Greatness of an Array

You are given an integer array nums. You can permute (rearrange) the elements of nums into a new array perm. Define the greatness of nums as the number of indices 0 <= i < nums.length where perm[i] > nums[i]. Your task is to return the maximum possible greatness you can achieve after permuting nums.

Leetcode 2593: Find Score of an Array After Marking All Elements

You are given an array nums consisting of positive integers. Starting with a score = 0, repeatedly select the smallest unmarked integer, add its value to the score, and mark it along with its adjacent elements (if any). Continue this until all elements are marked, then return the final score.