leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE | |
commit | 5e221eb2a6a54ecc54d3560acdad4db5f56adddb |
parent | fb34762967dd0c38ec9f9c7ca6a99a4603bf9163 |
author | Dimitrije Dobrota <mail@dimitrijedobrota.com> |
date | Fri, 27 Dec 2024 11:49:55 +0100 |
1 Random Problem
Diffstat:A | Problems/2102.cpp | | | ++++++++++++++ |
M | README.md | | | + |
2 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/Problems/2102.cpp b/Problems/2102.cpp
@@ -0,0 +1,14 @@
class SORTracker {
using type_t = tuple<int, string>;
set<type_t> st;
set<type_t>::iterator pos = end(st);
public:
void add(string name, int score) {
const auto it = st.insert({-score, name}).first;
if (pos == end(st) || *it < *pos) pos--;
}
const string &get() { return get<1>(*pos++); }
};
diff --git a/README.md b/README.md
@@ -1210,6 +1210,7 @@ reference and a base for solving problems.
| 2097 | Hard | [Valid Arrangement of Pairs](Problems/2097.cpp) |
| 2100 | Medium | [Find Good Days to Rob the Bank](Problems/2100.cpp) |
| 2101 | Medium | [Detonate the Maximum Bombs](Problems/2101.cpp) |
| 2102 | Hard | [Sequentially Ordinal Rank Tracker](Problems/2102.cpp) |
| 2104 | Medium | [Sum of Subarray Ranges](Problems/2104.cpp) |
| 2108 | Easy | [Find First Palindromic String in the Array](Problems/2108.cpp) |
| 2109 | Medium | [Adding Spaces to a String](Problems/2109.cpp) |