[Codeforces] Round #626 (Div. 2, based on Moscow Open Olympiad in Informatics) B. Count SubrectanglesRead more
[LeetCode] Check If Word Is Valid After Substitutions

1003. Check If Word Is Valid After Substitutions

Given a string s, determine if it is valid.

A string s is valid if, starting with an empty string t = “”, you can transform t into s after performing the following operation any number of times:

  • Insert string “abc” into any position in t. More formally, t becomes tleft + “abc” + tright, where t == tleft + tright. Note that tleft and tright may be empty.

Return true if s is a valid string, otherwise, return false.

Read more
[LeetCode] Before and After Puzzle

1181. Before and After Puzzle

Given a list of phrases, generate a list of Before and After puzzles.

A phrase is a string that consists of lowercase English letters and spaces only. No space appears in the start or the end of a phrase. There are no consecutive spaces in a phrase.

Before and After puzzles are phrases that are formed by merging two phrases where the last word of the first phrase is the same as the first word of the second phrase.

Return the Before and After puzzles that can be formed by every two phrases phrases[i] and phrases[j] where i != j. Note that the order of matching two phrases matters, we want to consider both orders.

You should return a list of distinct strings sorted lexicographically.

Read more
[LeetCode] Flip Columns For Maximum Number of Equal Rows

1072. Flip Columns For Maximum Number of Equal Rows

You are given an m x n binary matrix matrix.

You can choose any number of columns in the matrix and flip every cell in that column (i.e., Change the value of the cell from 0 to 1 or vice versa).

Return the maximum number of rows that have all values equal after some number of flips.

Read more
[LeetCode] Stepping Numbers

1215. Stepping Numbers

A stepping number is an integer such that all of its adjacent digits have an absolute difference of exactly 1.

  • For example, 321 is a stepping number while 421 is not.

Given two integers low and high, return a sorted list of all the stepping numbers in the inclusive range [low, high].

Read more
[LeetCode] Median of a Row Wise Sorted Matrix

2387. Median of a Row Wise Sorted Matrix

Given an m x n matrix grid containing an odd number of integers where each row is sorted in non-decreasing order, return the median of the matrix.

You must solve the problem in O(m * log(n)) time complexity.

Read more
[AtCoder] D - AtCoDeer and Rock-PaperRead more
[AtCoder] C - AtCoDeer and Election ReportRead more
[AtCoder] B - Painting Balls with AtCoDeerRead more
[AtCoder] D - An Invisible HandRead more