All Posts

Leetcode 1162: As Far from Land as Possible

Given a square grid of size n x n containing only 0s (water) and 1s (land), find the water cell that is farthest from any land cell based on Manhattan distance, and return that distance. If the grid has no water or no land, return -1.

Leetcode 1170: Compare Strings by Frequency of the Smallest Character

Define a function f(s) as the frequency of the lexicographically smallest character in a non-empty string s. For example, for s = 'abc', f(s) = 1 because the smallest character is 'a', appearing once. Given an array of strings queries and another array words, return an array where each entry corresponds to the number of strings in words where f(W) is greater than f(queries[i]) for a given i.

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 1186: Maximum Subarray Sum with One Deletion

Given an array of integers, determine the maximum sum of a non-empty contiguous subarray where you are allowed to optionally delete at most one element. The subarray must remain non-empty after any deletion.

Leetcode 1202: Smallest String With Swaps

You are given a string s and an array of pairs of indices pairs where each pair pairs[i] = [a, b] represents two indices in the string. You can swap the characters at any of these index pairs any number of times. Your task is to return the lexicographically smallest string that can be obtained after performing the swaps.

Leetcode 1207: Unique Number of Occurrences

Given an array of integers arr, return true if the number of occurrences of each value in the array is unique, and return false otherwise.