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 2711: Difference of Number of Distinct Values on Diagonals

Given a 2D grid of size m x n, you are tasked with finding a new matrix where each cell value is the absolute difference between the count of distinct values in the diagonal cells to the left and above it, and the count of distinct values in the diagonal cells to the right and below it.

Leetcode 2717: Semi-Ordered Permutation

You are given a permutation of integers from 1 to n. A permutation is called semi-ordered if the first element equals 1 and the last element equals n. You can perform the operation of swapping two adjacent elements as many times as needed to make the permutation semi-ordered. Your task is to return the minimum number of swaps required.

Leetcode 2718: Sum of Matrix After Queries

You are given a number n and a list of queries. Initially, an n x n matrix is filled with zeros. Each query updates either a row or a column in the matrix to a given value. After applying all the queries, compute and return the sum of all elements in the matrix.

Leetcode 2731: Movement of Robots

A number of robots are standing on an infinite number line with their initial positions given in the array nums. Each robot will move based on a command string s where ‘L’ means left and ‘R’ means right. If two robots collide, they instantly reverse their directions. Your task is to calculate the sum of the distances between all pairs of robots d seconds after the command.

Leetcode 2733: Neither Minimum nor Maximum

You are given an array nums containing distinct positive integers. Your task is to find and return any number from the array that is neither the smallest nor the largest number, or return -1 if no such number exists.