All Posts

Leetcode 2958: Length of Longest Subarray With at Most K Frequency

You are given an integer array nums and an integer k. The frequency of an element is the number of times it appears in the array. A subarray is called good if the frequency of each element in it is less than or equal to k. Your task is to return the length of the longest good subarray in nums.

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.

Leetcode 3026: Maximum Good Subarray Sum

You are given an array nums of length n and a positive integer k. A subarray is called good if the absolute difference between its first and last element is exactly k. The task is to return the maximum sum of any good subarray of nums. If no such subarray exists, return 0.

Leetcode 3043: Find the Length of the Longest Common Prefix

You are given two arrays arr1 and arr2 containing positive integers. Your task is to find the length of the longest common prefix between all pairs of integers (x, y) such that x belongs to arr1 and y belongs to arr2. A prefix of a number is any integer formed by one or more digits starting from its leftmost digit. For example, 123 is a prefix of 12345, but 234 is not. If no common prefix exists for any pair, return 0.

Leetcode 3044: Most Frequent Prime

You are given a matrix of integers, where each cell contains a digit from 1 to 9. Starting from any cell in the matrix, you can move in one of eight possible directions (east, south-east, south, south-west, west, north-west, north, and north-east) and create numbers by appending the digits along the path. For each valid path, numbers greater than 10 are generated. The task is to find the most frequent prime number greater than 10 among all the numbers generated by traversing the matrix. If there are multiple such prime numbers, return the largest one. If no prime number exists, return -1.