commit 7f2cf9b027c71b6c1c586a7f2e12741a76cd9889
parent 6d471b97cd0e07068ecb020bcfda401cbc704d72
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date: Wed, 29 Nov 2023 12:01:51 +0000
1 Random Problem
Diffstat:
2 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/Problems/2295.cpp b/Problems/2295.cpp
@@ -0,0 +1,17 @@
+class Solution {
+ public:
+ vector<int> arrayChange(vector<int> &nums, const vector<vector<int>> &operations) const {
+ static int position[1000001];
+
+ for (int i = 0; i < nums.size(); i++) {
+ position[nums[i]] = i;
+ }
+
+ for (const auto &op : operations) {
+ nums[position[op[0]]] = op[1];
+ position[op[1]] = position[op[0]];
+ }
+
+ return nums;
+ }
+}
diff --git a/README.md b/README.md
@@ -829,6 +829,7 @@ for solving problems.
| 2279 | Medium | [Maximum Bags With Full Capacity of Rocks](Problems/2279.cpp) |
| 2285 | Medium | [Maximum Total Importance of Roads](Problems/2285.cpp) |
| 2294 | Medium | [Partition Array Such That Maximum Difference Is K](Problems/2294.cpp) |
+| 2295 | Medium | [Replace Elements in an Array](Problems/2295.cpp) |
| 2300 | Medium | [Successful Pairs of Spells and Potions](Problems/2300.cpp) |
| 2304 | Medium | [Minimum Path Cost in a Grid](Problems/2304.cpp) |
| 2305 | Medium | [Fair Distribution of Cookies](Problems/2305.cpp) |