[Codeforces] Mail.Ru Cup 2018 - Practice Round B. DDoSRead more
[Codeforces] Round #523 (Div. 2) B. Views MatterRead more
[Codeforces] Round #515 (Div. 3) C. Books QueriesRead more
[Codeforces] Round #518 (Div. 2) [Thanks, Mail.Ru!] A. BirthdayRead more
[Codeforces] Round #525 (Div. 2) C. Ehab and a 2-operation taskRead more
[LeetCode] Subsequence of Size K With the Largest Even Sum

2098. Subsequence of Size K With the Largest Even Sum

You are given an integer array nums and an integer k. Find the largest even sum of any subsequence of nums that has a length of k.

Return this sum, or -1 if such a sum does not exist.

A subsequence is an array that can be derived from another array by deleting some or no elements without changing the order of the remaining elements.

Read more
[LeetCode] Check if Number is a Sum of Powers of Three

1780. Check if Number is a Sum of Powers of Three

Given an integer n, return true if it is possible to represent n as the sum of distinct powers of three. Otherwise, return false.

An integer y is a power of three if there exists an integer x such that y == 3x.

Read more
[LeetCode] Ways to Make a Fair Array

1664. Ways to Make a Fair Array

You are given an integer array nums. You can choose exactly one index (0-indexed) and remove the element. Notice that the index of the elements may change after the removal.

For example, if nums = [6,1,7,4,1]:

  • Choosing to remove index 1 results in nums = [6,7,4,1].
  • Choosing to remove index 2 results in nums = [6,1,4,1].
  • Choosing to remove index 4 results in nums = [6,1,7,4].

An array is fair if the sum of the odd-indexed values equals the sum of the even-indexed values.

Return the number of indices that you could choose such that after the removal, nums is fair.

Read more
[LeetCode] Tree Diameter

1245. Tree Diameter

The diameter of a tree is the number of edges in the longest path in that tree.

There is an undirected tree of n nodes labeled from 0 to n - 1. You are given a 2D array edges where edges.length == n - 1 and edges[i] = [ai, bi] indicates that there is an undirected edge between nodes ai and bi in the tree.

Return the diameter of the tree.

Read more
[LeetCode] Lonely Pixel I

531. Lonely Pixel I

Given an m x n picture consisting of black ‘B’ and white ‘W’ pixels, return the number of black lonely pixels.

A black lonely pixel is a character ‘B’ that located at a specific position where the same row and same column don’t have any other black pixels.

Read more