All Posts

Leetcode 1328: Break a Palindrome

Given a string palindrome that is a palindrome, you need to replace exactly one character with any lowercase English letter such that the resulting string is no longer a palindrome. The resulting string should be the lexicographically smallest string possible. If it is not possible to change the string to make it non-palindromic, return an empty string.

Leetcode 1329: Sort the Matrix Diagonally

You are given a matrix mat of integers with dimensions m x n. A matrix diagonal is a sequence of matrix elements that start from some cell in the topmost row or leftmost column and go diagonally towards the bottom-right corner. Your task is to sort each matrix diagonal in ascending order and return the resulting matrix.

Leetcode 1333: Filter Restaurants by Vegan-Friendly, Price and Distance

You are given a list of restaurants where each restaurant is represented by an array: [id, rating, veganFriendly, price, distance]. Filter these restaurants based on three criteria: vegan friendliness, maximum price, and maximum distance. Return the restaurant IDs, ordered by rating (highest first), and by ID (highest first) when ratings are tied.

Leetcode 1334: Find the City With the Smallest Number of Neighbors at a Threshold Distance

Given a set of cities connected by weighted edges, find the city with the least number of reachable cities under a distance threshold. If multiple cities have the same number of reachable cities, return the one with the greatest index.

Leetcode 1338: Reduce Array Size to The Half

You are given an integer array arr. You can choose a set of integers and remove all occurrences of these integers. Your task is to return the minimum size of the set such that at least half of the integers of the array are removed.

Leetcode 1339: Maximum Product of Splitted Binary Tree

Given the root of a binary tree, you need to split the tree into two subtrees by removing one edge. The goal is to maximize the product of the sums of these two subtrees. Return the maximum product of the sums of the two subtrees, modulo 10^9 + 7.