All Posts

Leetcode 1138: Alphabet Board Path

You are given an alphabet board. Starting at position (0, 0), you need to move around the board to form the target string using the minimum number of moves. The allowed moves are ‘U’, ‘D’, ‘L’, ‘R’, and ‘!’ to select the character at the current position.

Leetcode 1143: Longest Common Subsequence

Given two strings text1 and text2, return the length of their longest common subsequence. A subsequence is a sequence that can be derived from the string by deleting some characters without changing the order of the remaining characters.

Leetcode 1156: Swap For Longest Repeated Character Substring

You are given a string text. You can swap two characters in the string. The task is to find the length of the longest substring with repeated characters after the swap.

Leetcode 1160: Find Words That Can Be Formed by Characters

You are given an array of strings words and a string chars. A string is considered ‘good’ if it can be formed using characters from chars where each character can be used at most once. Your task is to return the sum of the lengths of all ‘good’ strings in words.

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.