All Posts

Leetcode 2762: Continuous Subarrays

You are given a 0-indexed integer array ’nums’. A subarray of ’nums’ is called continuous if the absolute difference between any two elements in the subarray is less than or equal to 2. Return the total number of continuous subarrays.

Leetcode 2799: Count Complete Subarrays in an Array

You are given an array ’nums’ consisting of positive integers. A subarray is called complete if the number of distinct elements in the subarray is equal to the number of distinct elements in the entire array. Return the total number of complete subarrays.

Leetcode 2831: Find the Longest Equal Subarray

You are given a list of integers nums and an integer k. Your task is to find the length of the longest subarray where all the elements are equal after you delete at most k elements.

Leetcode 2841: Maximum Sum of Almost Unique Subarray

You are given an integer array nums and two positive integers m and k. Return the maximum sum out of all almost unique subarrays of length k in nums. A subarray is almost unique if it contains at least m distinct elements. If no such subarray exists, return 0.

Leetcode 2875: Minimum Size Subarray in Infinite Array

You are given an array nums and an integer target. The array infinite_nums is created by infinitely appending nums to itself. You need to find the length of the shortest contiguous subarray in infinite_nums whose sum equals the target. If no such subarray exists, return -1.

Leetcode 2904: Shortest and Lexicographically Smallest Beautiful String

You are given a binary string s and a positive integer k. A substring of s is considered ‘beautiful’ if it contains exactly k occurrences of ‘1’. Your task is to return the lexicographically smallest substring of the shortest length that has exactly k ‘1’s. If no such substring exists, return an empty string.