[AtCoder] F - Playing Tag on TreeRead more
[Codeforces] Round #253 (Div. 2) B. Kolya and Tandem RepeatRead more
[Codeforces] Round #260 (Div. 1) A. BoredomRead more
[Codeforces] Round #262 (Div. 2) B. Little Dima and EquationRead more
[Codeforces] Round #268 (Div. 1) A. 24 GameRead more
[Codeforces] Round #279 (Div. 2) B. QueueRead more
[LeetCode] Number of Common Factors

2427. Number of Common Factors

Given two positive integers a and b, return the number of common factors of a and b.

An integer x is a common factor of a and b if x divides both a and b.

Read more
[LeetCode] Maximum Sum of an Hourglass

2428. Maximum Sum of an Hourglass

You are given an m x n integer matrix grid.

We define an hourglass as a part of the matrix with the following form:

Return the maximum sum of the elements of an hourglass.

Note that an hourglass cannot be rotated and must be entirely contained within the matrix.

Read more
[LeetCode] Minimize XOR

2429. Minimize XOR

Given two positive integers num1 and num2, find the integer x such that:

  • x has the same number of set bits as num2, and
  • The value x XOR num1 is minimal.

Note that XOR is the bitwise XOR operation.

Return the integer x. The test cases are generated such that x is uniquely determined.

The number of set bits of an integer is the number of 1’s in its binary representation.

Read more
[LeetCode] Maximum Deletions on a String

2430. Maximum Deletions on a String

You are given a string s consisting of only lowercase English letters. In one operation, you can:

  • Delete the entire string s, or
  • Delete the first i letters of s if the first i letters of s are equal to the following i letters in s, for any i in the range 1 <= i <= s.length / 2.

For example, if s = “ababc”, then in one operation, you could delete the first two letters of s to get “abc”, since the first two letters of s and the following two letters of s are both equal to “ab”.

Return the maximum number of operations needed to delete all of s.

Read more