[Codeforces] Round 969 (Div. 1) A. Iris and Game on the TreeRead more
[Codeforces] Round 969 (Div. 1) B. Iris and the TreeRead more
[Codeforces] Round 972 (Div. 2) C. Lazy NarekRead more
[Codeforces] Educational Round 169 (Rated for Div. 2) D. Colored PortalsRead more
[Hacker Cup 2024 Round 1] Problem D: Substitution CipherRead more
[Hacker Cup 2024 Round 1] Problem C: Substantial LossesRead more
[Hacker Cup 2024 Round 1] Problem B: Prime SubtractorizationRead more
[Hacker Cup 2024 Round 1] Problem A: Subsonic SubwayRead more
[LeetCode] Sorted GCD Pair Queries

3312. Sorted GCD Pair Queries

You are given an integer array nums of length n and an integer array queries.

Let gcdPairs denote an array obtained by calculating the GCD of all possible pairs (nums[i], nums[j]), where 0 <= i < j < n, and then sorting these values in ascending order.

For each query queries[i], you need to find the element at index queries[i] in gcdPairs.

Return an integer array answer, where answer[i] is the value at gcdPairs[queries[i]] for each query.

The term gcd(a, b) denotes the greatest common divisor of a and b.

Read more
[LeetCode] Construct 2D Grid Matching Graph Layout

3311. Construct 2D Grid Matching Graph Layout

You are given a 2D integer array edges representing an undirected graph having n nodes, where edges[i] = [ui, vi] denotes an edge between nodes ui and vi.

Construct a 2D grid that satisfies these conditions:

  • The grid contains all nodes from 0 to n - 1 in its cells, with each node appearing exactly once.
  • Two nodes should be in adjacent grid cells (horizontally or vertically) if and only if there is an edge between them in edges.

It is guaranteed that edges can form a 2D grid that satisfies the conditions.

Return a 2D integer array satisfying the conditions above. If there are multiple solutions, return any of them.

Read more