commit 51bb8de6006ad899b1ec3adcbe504e9c080fcbf1
parent e8126fedfa89c63b8819d1b5c9ab182b6e611040
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date: Mon, 16 Dec 2024 23:07:35 +0100
Daily Problem
Diffstat:
2 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/Problems/3264.cpp b/Problems/3264.cpp
@@ -0,0 +1,26 @@
+class Solution {
+ public:
+ vector<int> getFinalState(vector<int> &nums, int k, int multiplier) {
+ using type_t = pair<int, int>;
+ priority_queue<type_t, vector<type_t>, greater<>> pq;
+ const int n = size(nums);
+
+ for (int i = 0; i < n; i++) {
+ pq.emplace(nums[i], i);
+ }
+
+ while (k--) {
+ const auto [val, idx] = pq.top();
+ pq.pop();
+ pq.emplace(val * multiplier, idx);
+ }
+
+ while (!pq.empty()) {
+ const auto [val, idx] = pq.top();
+ pq.pop();
+ nums[idx] = val;
+ }
+
+ return nums;
+ }
+};
diff --git a/README.md b/README.md
@@ -1487,5 +1487,6 @@ reference and a base for solving problems.
| 3243 | Medium | [Shortest Distance After Road Addition Queries I](Problems/3243.cpp) |
| 3249 | Medium | [Count the Number of Good Nodes](Problems/3249.cpp) |
| 3254 | Medium | [Find the Power of K-Size Subarrays I](Problems/3254.cpp) |
+| 3264 | Easy | [Final Array State After K Multiplication Operations I](Problems/3264.cpp) |
| 3291 | Medium | [Minimum Number of Valid Strings to Form Target I](Problems/3291.cpp) |
| 3310 | Medium | [Remove Methods From Project](Problems/3310.cpp) |