Educational Codeforces Round 165 (Rated for Div. 2) D. Shop Game
590. N-ary Tree Postorder Traversal
Given the
root
of an n-ary tree, return the postorder traversal of its nodes’ values.Nary-Tree input serialization is represented in their level order traversal. Each group of children is separated by the null value (See examples)
3267. Count Almost Equal Pairs II
Attention: In this version, the number of operations that can be performed, has been increased to twice.
You are given an array
nums
consisting of positive integers.We call two integers
x
andy
almost equal if both integers can become equal after performing the following operation at most twice:
- Choose either
x
ory
and swap any two digits within the chosen number.Return the number of indices
i
andj
innums
wherei < j
such thatnums[i]
andnums[j]
are almost equal.Note that it is allowed for an integer to have leading zeros after performing an operation.
3266. Final Array State After K Multiplication Operations II
You are given an integer array
nums
, an integerk
, and an integermultiplier
.You need to perform
k
operations onnums
. In each operation:
- Find the minimum value
x
innums
. If there are multiple occurrences of the minimum value, select the one that appears first.- Replace the selected minimum value
x
withx * multiplier
.After the
k
operations, apply modulo109 + 7
to every value innums
.Return an integer array denoting the final state of
nums
after performing allk
operations and then applying the modulo.