commit a0d3ce4aff8b642353244e3dc4c053ee84c5fef0
parent 83959563e1f1525d34518c7624f3caa174db4d15
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date: Wed, 27 Sep 2023 22:17:13 +0000
Daily Problem
Diffstat:
2 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/Problems/0880.cpp b/Problems/0880.cpp
@@ -0,0 +1,20 @@
+class Solution {
+ public:
+ string decodeAtIndex(const string &s, int k) {
+ long n = 0, idx;
+
+ for (idx = 0; n < k; idx++) {
+ n = isdigit(s[idx]) ? n * (s[idx] & 0x0F) : n + 1;
+ }
+
+ while (idx--) {
+ if (isdigit(s[idx]))
+ n /= s[idx] & 0x0F, k %= n;
+ else if (k % n == 0)
+ return string(1, s[idx]);
+ else
+ n--;
+ }
+ return "";
+ }
+};
diff --git a/README.md b/README.md
@@ -429,6 +429,7 @@ for solving problems.
| 0876 | Easy | [Middle of the Linked List](Problems/0876.cpp) |
| 0877 | Medium | [Stone Game](Problems/0877.cpp) |
| 0879 | Hard | [Profitable Schemes](Problems/0879.cpp) |
+| 0880 | Medium | [Decoded String at Index](Problems/0880.cpp) |
| 0881 | Medium | [Boats to Save People](Problems/0881.cpp) |
| 0884 | Easy | [Uncommon Words from Two Sentences](Problems/0884.cpp) |
| 0885 | Medium | [Spiral Matrix III](Problems/0885.cpp) |