All Posts

Leetcode 647: Palindromic Substrings

Given a string s, return the number of palindromic substrings in it. A palindrome is a string that reads the same forward and backward. A substring is a contiguous sequence of characters within the string.

Leetcode 658: Find K Closest Elements

Given a sorted integer array and two integers k and x, return the k closest integers to x in the array, sorted in ascending order. If two integers are equally close to x, the smaller integer should be preferred.

Leetcode 763: Partition Labels

You are given a string s. Your task is to divide the string into the maximum number of parts such that each letter appears in at most one part. The resulting parts, when concatenated in order, should form the original string.

Leetcode 777: Swap Adjacent in LR String

You are given a string start and a string result composed of the characters ‘L’, ‘R’, and ‘X’. A move consists of either replacing an occurrence of ‘XL’ with ‘LX’, or replacing an occurrence of ‘RX’ with ‘XR’. Return true if it is possible to transform start into result by applying a sequence of these moves.

Leetcode 786: K-th Smallest Prime Fraction

You are given a sorted array of prime numbers and the number 1. You need to find the k-th smallest fraction formed by considering all possible fractions arr[i] / arr[j] where i < j. Return the k-th smallest fraction as an array of two integers, where arr[i] is the numerator and arr[j] is the denominator.

Leetcode 795: Number of Subarrays with Bounded Maximum

Given an integer array nums and two integers left and right, return the number of contiguous non-empty subarrays such that the maximum value in each subarray lies within the inclusive range [left, right].