[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
[LeetCode] Remove Methods From Project

3310. Remove Methods From Project

You are maintaining a project that has n methods numbered from 0 to n - 1.

You are given two integers n and k, and a 2D integer array invocations, where invocations[i] = [ai, bi] indicates that method ai invokes method bi.

There is a known bug in method k. Method k, along with any method invoked by it, either directly or indirectly, are considered suspicious and we aim to remove them.

A group of methods can only be removed if no method outside the group invokes any methods within it.

Return an array containing all the remaining methods after removing all the suspicious methods. You may return the answer in any order. If it is not possible to remove all the suspicious methods, none should be removed.

Read more
[LeetCode] Maximum Possible Number by Binary Concatenation

3309. Maximum Possible Number by Binary Concatenation

You are given an array of integers nums of size 3.

Return the maximum possible number whose binary representation can be formed by concatenating the binary representation of all elements in nums in some order.

Note that the binary representation of any number does not contain leading zeros.

Read more
[Codeforces] EPIC Institute of Technology Round August 2024 (Div. 1 + Div. 2) D1. DFS Checker (Easy Version)Read more
[Codeforces] Round 967 (Div. 2) D. Longest Max Min SubsequenceRead more
[Codeforces] Round 966 (Div. 3) F. Color Rows and ColumnsRead more
[Codeforces] Round 964 (Div. 4) G2. Ruler (hard version)Read more
[LeetCode] Rank Transform of an Array

1331. Rank Transform of an Array

Given an array of integers arr, replace each element with its rank.

The rank represents how large the element is. The rank has the following rules:

  • Rank is an integer starting from 1.
  • The larger the element, the larger the rank. If two elements are equal, their rank must be the same.
  • Rank should be as small as possible.
Read more
[Codeforces] Round 965 (Div. 2) C. Perform Operations to Maximize ScoreRead more
[Codeforces] Round 962 (Div. 3) F. BombRead more