304 North Cardinal St.
Dorchester Center, MA 02124

Category Leetcode Solution

Largest 3-Same-Digit Number in String LeetCode Solution

Problem – Largest 3-Same-Digit Number in String LeetCode Solution You are given a string num representing a large integer. An integer is good if it meets the following conditions: It is a substring of num with length 3. It consists of only one unique digit. Return the maximum good integer as a string or…

Count Nodes Equal to Average of Subtree LeetCode Solution

Problem – Count Nodes Equal to Average of Subtree leetCode Solution Given the root of a binary tree, return the number of nodes where the value of the node is equal to the average of the values in its subtree. Note: The average of n elements is the sum of the n elements divided…

Count Number of Texts LeetCode Solution

Problem – Count Number of Texts LeetCode Solutions Alice is texting Bob using her phone. The mapping of digits to letters is shown in the figure below. In order to add a letter, Alice has to press the key of the corresponding digit i times, where i is the position…

Check if There Is a Valid Parentheses String Path LeetCode Solution

Problem – Check if There Is a Valid Parentheses String Path LeetCode Solution A parentheses string is a non-empty string consisting only of ‘(‘ and ‘)’. It is valid if any of the following conditions is true: You are given an m x n matrix of parentheses grid. A valid parentheses string path in the…

Rearrange Characters to Make Target String LeetCode Solution

Problem – Rearrange Characters to Make Target String LeetCode Solution You are given two 0-indexed strings s and target. You can take some letters from s and rearrange them to form new strings. Return the maximum number of copies of target that can be formed by taking letters from s and rearranging them. Example…

Minimize Result by Adding Parentheses to Expression Solution – LeetCode

Problem: Minimize Result by Adding Parentheses to Expression Solution You are given a 0-indexed string expression of the form “<num1> <num2>” where <num1> and <num2> represent positive integers. Add a pair of parentheses to expression such that after the addition of parentheses, expression is a valid mathematical expression and evaluates to the smallest possible value. The left parenthesis must be…

Largest Number After Digit Swaps by Parity Solution – LeetCode

Problem Statement: Largest Number After Digit Swaps by Parity Solution You are given a positive integer num. You may swap any two digits of num that have the same parity (i.e. both odd digits or both even digits). Return the largest possible value of num after any number of swaps. Example 1:…

Maximum Number of Events That Can Be Attended Leetcode Solution

Problem: Maximum Number of Events That Can Be Attended Leetcode Maximum Number of Events That Can Be Attended Leetcode Solution Maximum Number of Events That Can Be Attended Leetcode Solution Review: In our experience, we suggest you solve this Maximum…