All Posts

Leetcode 1177: Can Make Palindrome from Substring

You are given a string s and an array of queries queries, where queries[i] = [lefti, righti, ki]. For each query, you can rearrange the substring s[lefti...righti] and replace up to ki characters in it with any lowercase English letters. Determine whether it is possible to form a palindrome from the resulting substring. Return an array of booleans answer where answer[i] is true if it is possible to form a palindrome for the i-th query, otherwise false.

Leetcode 1208: Get Equal Substrings Within Budget

You are given two strings s and t of the same length, and an integer maxCost. You want to change string s to string t. The cost of changing the ith character of s to the ith character of t is the absolute difference between their ASCII values. Your task is to find the maximum length of a substring of s that can be changed to match the corresponding substring of t, with the total cost not exceeding maxCost.

Leetcode 1248: Count Number of Nice Subarrays

You are given an array of integers nums and an integer k. A subarray is considered ’nice’ if it contains exactly k odd numbers. Your task is to return the number of nice subarrays in the given array.

Leetcode 1292: Maximum Side Length of a Square with Sum Less than or Equal to Threshold

You are given a matrix of integers and a threshold. Your goal is to find the maximum side length of a square where the sum of the elements inside the square is less than or equal to the threshold.

Leetcode 1310: XOR Queries of a Subarray

You are given an array of positive integers arr and an array of queries. For each query [lefti, righti], calculate the XOR of elements from index lefti to righti (inclusive). Return an array answer where each element corresponds to the XOR result of the respective query.

Leetcode 1314: Matrix Block Sum

Given a matrix of integers, where each element represents a value, you need to calculate the sum of all elements in a sub-matrix for each cell. For each cell, the sub-matrix includes all elements within a square grid of size (2k+1) x (2k+1) centered at that cell. If the sub-matrix extends beyond the boundaries of the matrix, only the valid elements within the matrix should be considered.