All Posts

Leetcode 792: Number of Matching Subsequences

You are given a string s and an array of strings words. Your task is to determine how many words from the array are subsequences of the string s. A subsequence of a string is derived by deleting some or no characters from the original string without altering the order of the remaining characters.

Leetcode 809: Expressive Words

You are given a string s and a list of query words. Each word in the query list is said to be ‘stretchy’ if it can be transformed into string s by extending groups of adjacent letters. You can extend a group of letters (e.g., ‘a’, ‘bb’, ‘ccc’) as long as its length is at least 3. For example, if s = ‘heeellooo’, you could extend ’e’ and ‘o’ to make ‘hello’ stretchy. Return the number of query strings that can be stretched to become s.

Leetcode 811: Subdomain Visit Count

You are given a list of count-paired domains, where each entry consists of a number followed by a domain name. The number represents the number of visits to that domain. A domain may also have subdomains, and visiting a subdomain also counts as visiting its parent domains. Your task is to return the count of visits for each domain and its subdomains.

Leetcode 816: Ambiguous Coordinates

You are given a string s representing coordinates that have been encoded by removing commas, decimal points, and spaces. Your task is to restore the coordinates to their original form by considering all possible valid ways the digits could be split into two parts: a left part representing the x-coordinate and a right part representing the y-coordinate. Both parts may optionally contain a decimal point. The final coordinates must follow specific rules: no leading zeros are allowed, and the decimal point must be placed correctly. Return a list of all possible valid coordinates, formatted as ‘(x, y)’, where x and y represent the respective coordinates.

Leetcode 820: Short Encoding of Words

Given an array of words, you are to return the length of the shortest reference string that can encode these words. The reference string consists of the words concatenated with a ‘#’ character at the end, and indices are used to encode the words by identifying their position in the reference string. Each word is encoded by the substring in the reference string that starts at its position and ends at the next ‘#’.

Leetcode 824: Goat Latin

You are given a sentence with words separated by spaces. Each word consists of only lowercase and uppercase letters. Your task is to convert the sentence into a new language called ‘Goat Latin’ by following the rules below:

  1. If a word begins with a vowel (‘a’, ’e’, ‘i’, ‘o’, or ‘u’), append ‘ma’ to the end of the word.
  2. If a word begins with a consonant, remove the first letter, move it to the end, and add ‘ma’.
  3. Add one letter ‘a’ to the end of each word depending on its position in the sentence (1st word gets ‘a’, 2nd gets ‘aa’, 3rd gets ‘aaa’, etc.).

Return the final sentence in Goat Latin.