All Posts

Leetcode 1678: Goal Parser Interpretation

You are given a string command consisting of the characters ‘G’, ‘()’, and ‘(al)’ in some order. The Goal Parser interprets the following patterns: ‘G’ as the string ‘G’, ‘()’ as the string ‘o’, and ‘(al)’ as the string ‘al’. Return the interpreted string after replacing all instances of ‘()’, ‘(al)’, and ‘G’ according to the above rules.

Leetcode 1684: Count the Number of Consistent Strings

You are given a string allowed consisting of distinct characters, and an array of strings words. A string is consistent if all characters in the string appear in the string allowed. Return the number of consistent strings in the array words.

Leetcode 1688: Count of Matches in Tournament

In a tournament with n teams, each round involves pairing teams for matches. The number of matches depends on whether n is even or odd. Calculate the total number of matches played in the tournament until a winner is determined.

Leetcode 1694: Reformat Phone Number

You are given a phone number as a string. The string consists of digits, spaces, and/or dashes. Your task is to reformat the phone number by removing spaces and dashes, then grouping the digits into blocks of length 3 until there are at most 4 digits left. Afterward, follow specific grouping rules for the remaining digits and join the blocks with dashes.

Leetcode 1700: Number of Students Unable to Eat Lunch

In a school cafeteria, sandwiches are placed in a stack and students queue up to get one. Each student has a preference for the type of sandwich, and they either take the sandwich from the stack or move to the back of the queue if the sandwich is not to their liking. The goal is to determine how many students are unable to get a sandwich.

Leetcode 1704: Determine if String Halves Are Alike

You are given a string ’s’ of even length. Split the string into two equal halves, where the first half is ‘a’ and the second half is ‘b’.

Two strings are considered alike if they contain the same number of vowels (a, e, i, o, u, A, E, I, O, U). Return ’true’ if ‘a’ and ‘b’ are alike, otherwise return ‘false’.