All Posts

Leetcode 2708: Maximum Strength of a Group

You are given an integer array representing the scores of students in an exam. Your task is to form a non-empty group of students such that the group’s strength, defined as the product of their scores, is maximized. The goal is to return the maximum possible strength that can be achieved by choosing an optimal group of students.

Leetcode 2735: Collecting Chocolates

You are given an array nums where each element represents the cost of collecting a chocolate of a specific type. You can perform an operation to change the types of chocolates, and each operation incurs a cost. Your task is to determine the minimum total cost to collect all types of chocolates.

Leetcode 2761: Prime Pairs With Target Sum

You are given an integer ’n’. Your task is to find all pairs of prime numbers [x, y] such that 1 <= x <= y <= n, x + y = n, and both x and y are prime numbers. Return a 2D sorted list of such prime pairs. If no such pairs exist, return an empty array.

Leetcode 2765: Longest Alternating Subarray

You are given a 0-indexed integer array ’nums’. A subarray ’s’ is called alternating if it follows a specific pattern of alternating differences between consecutive elements: +1, -1, +1, -1, and so on. Return the maximum length of all alternating subarrays, or -1 if no such subarray exists.

Leetcode 2768: Number of Black Blocks

Given an m x n grid with some black cells specified by a coordinates list, determine how many 2x2 blocks contain exactly 0, 1, 2, 3, or 4 black cells.

Leetcode 2778: Sum of Squares of Special Elements

Given a 1-indexed integer array nums of length n, an element nums[i] is considered special if the index i divides the length n (i.e., n % i == 0). Your task is to find the sum of the squares of all special elements in the array.