Leet code problem 1930: – Unique Length-3 Palindromic Subsequences

Given a string s, return the number of unique palindromes of length three that are a subsequence of s. Note that even if there are multiple ways to obtain the same subsequence, it is still only counted once. A palindrome is a string that reads the same forwards and backwards. A subsequence of a string…

Leet code problem 1805: – Number of Different Integers in a String

You are given a string word that consists of digits and lowercase English letters. You will replace every non-digit character with a space. For example, “a123bc34d8ef34″ will become ” 123 34 8 34″. Notice that you are left with some integers that are separated by at least one space: “123”, “34”, “8”, and “34”. Return…

Leet code 1796: – Second Largest Digit in a String

Given an alphanumeric string s, return the second largest numerical digit that appears in s, or -1 if it does not exist. An alphanumeric string is a string consisting of lowercase English letters and digits. Example 1: Input: s = “dfa12321afd”Output: 2Explanation: The digits that appear in s are [1, 2, 3]. The second largest…

Leet code 1901: – Find a Peak Element II

A peak element in a 2D grid is an element that is strictly greater than all of its adjacent neighbors to the left, right, top, and bottom. Given a 0-indexed m x n matrix mat where no two adjacent cells are equal, find any peak element mat[i][j] and return the length 2 array [i,j]. You…