Uncategorized

Check if There Is a Valid Parentheses String Path solution leetcode

Check if There Is a Valid Parentheses String Path solution leetcode A parentheses string is a non-empty string consisting only of ‘(‘ and ‘)’. It is valid if any of the following conditions is true: It is (). It can be written as AB (A concatenated with B), where A and B are valid parentheses strings. It can be written as (A), where A is a valid parentheses string. You are given an m x n matrix of parentheses grid. …

Check if There Is a Valid Parentheses String Path solution leetcode Read More »

Count Number of Texts solution leetcode

Count Number of Texts solution leetcode 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 of the letter in the key. For example, to add the letter ‘s’, Alice has to press ‘7’ four times. …

Count Number of Texts solution leetcode Read More »

Count Nodes Equal to Average of Subtree solution leetcode

Count Nodes Equal to Average of Subtree solution leetcode 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 by n and rounded down to the nearest integer. A subtree of root is a tree consisting of root and all of its descendants. Count Nodes Equal …

Count Nodes Equal to Average of Subtree solution leetcode Read More »

Largest 3-Same-Digit Number in String solution leetcode

Largest 3-Same-Digit Number in String solution leetcode 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 an empty string “” if no such integer exists. Note: A substring is a contiguous sequence of characters within a string. …

Largest 3-Same-Digit Number in String solution leetcode Read More »

Jee, You See? solution codeforces- During their training for the ICPC competitions, team “Jee You See” stumbled upon a very basic counting problem. After many “Wrong answer” verdicts, they finally decided to give up and destroy turn-off the PC. Now they want your help in up-solving the problem.

 Jee, You See? solution codeforces   During their training for the ICPC competitions, team “Jee You See” stumbled upon a very basic counting problem. After many “Wrong answer” verdicts, they finally decided to give up and destroy turn-off the PC. Now they want your help in up-solving the problem. You are given 4 integers nn, ll, rr, and zz. Count the …

Jee, You See? solution codeforces- During their training for the ICPC competitions, team “Jee You See” stumbled upon a very basic counting problem. After many “Wrong answer” verdicts, they finally decided to give up and destroy turn-off the PC. Now they want your help in up-solving the problem. Read More »

 Hemose on the Tree solution codeforces- After the last regional contest, Hemose and his teammates finally qualified to the ICPC World Finals, so for this great achievement and his love of trees, he gave you this problem as the name of his team “Hemose 3al shagra” (Hemose on the tree).

 Hemose on the Tree solution codeforces   After the last regional contest, Hemose and his teammates finally qualified to the ICPC World Finals, so for this great achievement and his love of trees, he gave you this problem as the name of his team “Hemose 3al shagra” (Hemose on the tree). You are given a …

 Hemose on the Tree solution codeforces- After the last regional contest, Hemose and his teammates finally qualified to the ICPC World Finals, so for this great achievement and his love of trees, he gave you this problem as the name of his team “Hemose 3al shagra” (Hemose on the tree). Read More »

Hemose on the Tree solution codeforces- After the last regional contest, Hemose and his teammates finally qualified to the ICPC World Finals, so for this great achievement and his love of trees, he gave you this problem as the name of his team “Hemose 3al shagra” (Hemose on the tree).

 Hemose on the Tree solution codeforces   After the last regional contest, Hemose and his teammates finally qualified to the ICPC World Finals, so for this great achievement and his love of trees, he gave you this problem as the name of his team “Hemose 3al shagra” (Hemose on the tree). You are given a …

Hemose on the Tree solution codeforces- After the last regional contest, Hemose and his teammates finally qualified to the ICPC World Finals, so for this great achievement and his love of trees, he gave you this problem as the name of his team “Hemose 3al shagra” (Hemose on the tree). Read More »

Very Suspicious solution codeforces- Sehr Sus is an infinite hexagonal grid as pictured below, controlled by MennaFadali, ZerooCool and Hosssam.

Very Suspicious solution codeforces Sehr Sus is an infinite hexagonal grid as pictured below, controlled by MennaFadali, ZerooCool and Hosssam. They love equilateral triangles and want to create nn equilateral triangles on the grid by adding some straight lines. The triangles must all be empty from the inside (in other words, no straight line or hexagon edge …

Very Suspicious solution codeforces- Sehr Sus is an infinite hexagonal grid as pictured below, controlled by MennaFadali, ZerooCool and Hosssam. Read More »

Where is the Pizza? solution codeforces- While searching for the pizza, baby Hosssam came across two permutations aa and bb of length nn.

Where is the Pizza? solution codeforces While searching for the pizza, baby Hosssam came across two permutations aa and bb of length nn. Recall that a permutation is an array consisting of nn distinct integers from 11 to nn in arbitrary order. For example, [2,3,1,5,4][2,3,1,5,4] is a permutation, but [1,2,2][1,2,2] is not a permutation (22 appears twice in the array) and [1,3,4][1,3,4] is also not a permutation (n=3n=3 but there is 44 in the array). Baby …

Where is the Pizza? solution codeforces- While searching for the pizza, baby Hosssam came across two permutations aa and bb of length nn. Read More »

Dorms War solution codeforces- Hosssam decided to sneak into Hemose’s room while he is sleeping and change his laptop’s password. He already knows the password, which is a string ss of length nn. He also knows that there are kk special letters of the alphabet: c1,c2,…,ckc1,c2,…,ck.

Dorms War solution codeforces Hosssam decided to sneak into Hemose’s room while he is sleeping and change his laptop’s password. He already knows the password, which is a string ss of length nn. He also knows that there are kk special letters of the alphabet: c1,c2,…,ckc1,c2,…,ck. Hosssam made a program that can do the following. The program considers the current password ss of some …

Dorms War solution codeforces- Hosssam decided to sneak into Hemose’s room while he is sleeping and change his laptop’s password. He already knows the password, which is a string ss of length nn. He also knows that there are kk special letters of the alphabet: c1,c2,…,ckc1,c2,…,ck. Read More »