All Posts

Leetcode 2053: Kth Distinct String in an Array

Find the k-th unique string in an array based on its first occurrence. If fewer than k unique strings exist, return an empty string.

Leetcode 2068: Check Whether Two Strings are Almost Equivalent

You are given two strings, word1 and word2, each of length n. The two strings are considered almost equivalent if the difference in frequency of each letter between word1 and word2 is at most 3. Return true if they are almost equivalent, or false otherwise.

Leetcode 2080: Range Frequency Queries

Design a data structure that allows you to efficiently find the frequency of a given value in a subarray. Implement the class RangeFreqQuery with the following methods:

  • RangeFreqQuery(int[] arr) initializes the data structure.
  • int query(int left, int right, int value) returns the frequency of value in the subarray from left to right.

Leetcode 2099: Find Subsequence of Length K With the Largest Sum

You are given an integer array ’nums’ and an integer ‘k’. You need to find a subsequence of ’nums’ of length ‘k’ such that the sum of its elements is maximized. A subsequence is a sequence that can be derived from another array by deleting some or no elements without changing the order of the remaining elements. Return any subsequence with the largest sum.

Leetcode 2121: Intervals Between Identical Elements

You are given an array of integers. Your task is to calculate the sum of absolute differences between the index of each element and the indices of all other occurrences of the same element. For each element in the array, return the sum of intervals to all its identical elements in the array.

Leetcode 2131: Longest Palindrome by Concatenating Two Letter Words

You are given an array of strings, where each string consists of two lowercase English letters. The task is to create the longest possible palindrome by selecting some of these strings and concatenating them in any order. Each string can be used at most once. A palindrome is a string that reads the same forward and backward. Return the length of the longest palindrome that can be created, or 0 if it’s not possible to create any palindrome.