[LeetCode] Restore the Array From Adjacent Pairs

1743. Restore the Array From Adjacent Pairs

There is an integer array nums that consists of n unique elements, but you have forgotten it. However, you do remember every pair of adjacent elements in nums.

You are given a 2D integer array adjacentPairs of size n - 1 where each adjacentPairs[i] = [ui, vi] indicates that the elements ui and vi are adjacent in nums.

It is guaranteed that every adjacent pair of elements nums[i] and nums[i+1] will exist in adjacentPairs, either as [nums[i], nums[i+1]] or [nums[i+1], nums[i]]. The pairs can appear in any order.

Return the original array nums. If there are multiple solutions, return any of them.

Read more
[LeetCode] Rotating the Box

1861. Rotating the Box

You are given an m x n matrix of characters box representing a side-view of a box. Each cell of the box is one of the following:

  • A stone ‘#’
  • A stationary obstacle ‘*’
  • Empty ‘.’

The box is rotated 90 degrees clockwise, causing some of the stones to fall due to gravity. Each stone falls down until it lands on an obstacle, another stone, or the bottom of the box. Gravity does not affect the obstacles’ positions, and the inertia from the box’s rotation does not affect the stones’ horizontal positions.

It is guaranteed that each stone in box rests on an obstacle, another stone, or the bottom of the box.

Return an n x m matrix representing the box after the rotation described above.

Read more
[AtCoder] D - Number of Shortest pathsRead more
[AtCoder] C - chokudaiRead more
[AtCoder] B - XOR Matching 2Read more
[AtCoder] E - Safety JourneyRead more
[AtCoder] D - Querying MultisetRead more
[Codeforces] Round #550 (Div. 3) D. Equalize Them AllRead more
[Codeforces] Round #552 (Div. 3) C. Gourmet CatRead more
[Codeforces] Educational Round 64 (Rated for Div. 2) A. Inscribed FiguresRead more