Codeforces Round 943 (Div. 3) G1. Division + LCP (easy version)
590. N-ary Tree Postorder Traversal
Given the
rootof 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
numsconsisting of positive integers.We call two integers
xandyalmost equal if both integers can become equal after performing the following operation at most twice:
- Choose either
xoryand swap any two digits within the chosen number.Return the number of indices
iandjinnumswherei < jsuch 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
koperations onnums. In each operation:
- Find the minimum value
xinnums. If there are multiple occurrences of the minimum value, select the one that appears first.- Replace the selected minimum value
xwithx * multiplier.After the
koperations, apply modulo109 + 7to every value innums.Return an integer array denoting the final state of
numsafter performing allkoperations and then applying the modulo.
3265. Count Almost Equal Pairs I
You are given an array
numsconsisting of positive integers.We call two integers
xandyin this problem almost equal if both integers can become equal after performing the following operation at most once:
- Choose either
xoryand swap any two digits within the chosen number.Return the number of indices
iandjinnumswherei < jsuch thatnums[i]andnums[j]are almost equal.Note that it is allowed for an integer to have leading zeros after performing an operation.