All Posts

Leetcode 2217: Find Palindrome With Fixed Length

You are given an array of queries and a positive integer intLength. For each query, you need to find the query-th smallest palindrome of length intLength. A palindrome is a number that reads the same backward and forward, and it cannot have leading zeros. If no such palindrome exists for a query, return -1.

Leetcode 2221: Find Triangular Sum of an Array

You are given a 0-indexed integer array nums, where each element is a digit between 0 and 9. The triangular sum of nums is computed by repeatedly reducing the array by replacing each element with the sum of two consecutive elements, modulo 10. This process continues until only one element remains, which is the triangular sum. Your task is to return the triangular sum of the array.

Leetcode 2222: Number of Ways to Select Buildings

You are given a binary string s that represents the types of buildings along a street. Each building is either an office (‘0’) or a restaurant (‘1’). You are tasked with selecting 3 buildings for inspection, with the constraint that no two consecutive buildings in the selection can be of the same type. Return the number of valid ways to select 3 buildings where no two consecutive buildings are of the same type.

Leetcode 2225: Find Players With Zero or One Losses

You are given an array matches where each element matches[i] = [winneri, loseri] indicates that player winneri defeated player loseri in a match. Your task is to return a list answer of size 2 where:

  • answer[0] contains the list of players who have never lost a match.
  • answer[1] contains the list of players who have lost exactly one match.

The players in both lists should be sorted in increasing order.

Leetcode 2226: Maximum Candies Allocated to K Children

You are given a 0-indexed integer array candies, where each element represents the number of candies in a pile. You also have an integer k, which is the number of children. You need to distribute the candies into k piles such that each child gets the same number of candies. Each child can receive at most one pile, and some piles may go unused. Your task is to return the maximum number of candies each child can receive.

Leetcode 2232: Minimize Result by Adding Parentheses to Expression

You are given a string expression in the form ‘+’, where and represent positive integers. Your task is to add a pair of parentheses to the expression such that the resulting expression evaluates to the smallest possible value. The parentheses must be placed around the ‘+’ operator. If there are multiple valid solutions yielding the same result, any of them can be returned.