All Posts

Leetcode 2946: Matrix Similarity After Cyclic Shifts

You are given an m x n matrix ‘mat’ and an integer ‘k’. The rows of the matrix undergo cyclic shifts: even-indexed rows shift left, and odd-indexed rows shift right. After performing these k shifts, determine if the matrix is identical to its original form.

Leetcode 2951: Find the Peaks

You are given a list called mountain, which contains integers. Your task is to find all the indices that represent peaks in the list. A peak is defined as an element that is strictly greater than its immediate left and right neighbors. The first and last elements of the list cannot be peaks. Return a list of indices that correspond to the peaks in the mountain array.

Leetcode 2956: Find Common Elements Between Two Arrays

You are given two integer arrays, nums1 and nums2, with sizes n and m respectively. Your task is to find the number of indices i such that nums1[i] exists in nums2 and the number of indices i such that nums2[i] exists in nums1. Return both values as an array [answer1, answer2].

Leetcode 2960: Count Tested Devices After Test Operations

You are given an integer array batteryPercentages representing the battery levels of devices. Perform tests on each device in order, testing a device if its battery percentage is greater than 0 and decrementing the battery percentage of all subsequent devices by 1. Return the number of devices that can be tested after performing the operations.

Leetcode 2965: Find Missing and Repeated Values

You are given a 2D integer matrix grid of size n * n. The matrix contains integers in the range [1, n²], and each number appears exactly once, except for two numbers. One number a is repeated twice, and another number b is missing. Find the repeating and missing numbers a and b.

Leetcode 3005: Count Elements With Maximum Frequency

You are given an array nums containing positive integers. Your task is to find the total frequency of the elements in nums that appear the maximum number of times. The frequency of an element is defined as the number of times that element occurs in the array. You need to return the sum of frequencies of all elements that have the maximum frequency.