304 North Cardinal St.
Dorchester Center, MA 02124

# Category Leetcode Solution

## Weekly Contest 300 LeetCode Solution

Problem 1 – Decode the Message LeetCode Solution You are given the strings key and message, which represent a cipher key and a secret message, respectively. The steps to decode message are as follows: Use the first appearance of all 26 lowercase English letters in key as the order of the…

## Weekly Contest 299 LeetCode Solution

Problem 1 – Check if Matrix Is X-Matrix LeetCode Solution A square matrix is said to be an X-Matrix if both of the following conditions hold: All the elements in the diagonals of the matrix are non-zero. All other elements are 0. Given a 2D…

## Biweekly Contest 81 Leetcode Solution

Problem 1 – Count Asterisks Leetcode Solution You are given a string s, where every two consecutive vertical bars ‘|’ are grouped into a pair. In other words, the 1st and 2nd ‘|’ make a pair, the 3rd and 4th ‘|’ make a pair, and so forth. Return the number of ‘*’ in s, excluding the ‘*’ between each pair…

## Biweekly Contest 68 LeetCode Solution

Problem 1 – Maximum Number of Words Found in Sentences LeetCode Solution A sentence is a list of words that are separated by a single space with no leading or trailing spaces. You are given an array of strings sentences, where each sentences[i] represents a single sentence. Return the maximum number…

## Weekly Contest 298 LeetCode Solution

Problem 1 – Greatest English Letter in Upper and Lower Case LeetCode Solution Given a string of English letters s, return the greatest English letter which occurs as both a lowercase and uppercase letter in s. The returned letter should be in uppercase. If no such letter exists,…

## Weekly Contest 273 LeetCode Solution

Problem 1 – A Number After a Double Reversal LeetCode Solution Reversing an integer means to reverse all its digits. For example, reversing 2021 gives 1202. Reversing 12300 gives 321 as the leading zeros are not retained. Given an integer num, reverse num to get reversed1, then reverse reversed1 to get reversed2. Return true if reversed2 equals num. Otherwise return false. Example 1: Example…

## Weekly Contest 274 LeetCode Solution

Problem 1 – Check if All A’s Appears Before All B’s LeetCode Solution Given a string s consisting of only the characters ‘a’ and ‘b’, return true if every ‘a’ appears before every ‘b’ in the string. Otherwise, return false. Example 1: Example 2: Example 3: Constraints: 1 <= s.length <= 100 s[i] is either ‘a’ or ‘b’. Check if…

## Biweekly Contest 69 LeetCode Solution

Problem 1 – Capitalize the Title Leetcode Solution You are given a string title consisting of one or more words separated by a single space, where each word consists of English letters. Capitalize the string by changing the capitalization of each word such that:…

## Weekly Contest 275 LeetCode Solution

Problem 1 – Check if Every Row and Column Contains All Numbers Leetcode Solution An n x n matrix is valid if every row and every column contains all the integers from 1 to n (inclusive). Given an n x n integer matrix matrix, return true if the matrix is valid. Otherwise, return false. Example 1: Example 2:…

## Weekly Contest 276 LeetCode Solution

Problem 1 – Divide a String Into Groups of Size k Leetcode Solution A string s can be partitioned into groups of size k using the following procedure: The first group consists of the first k characters of the string, the second group consists of the…