commit 541fb16da7ff5184ebf405b0bc9fa3abf617c24e parent f626d2f685e5f44a350184ef3ee9218c79d43a0f Author: Dimitrije Dobrota <mail@dimitrijedobrota.com> Date: Fri, 9 Jun 2023 21:40:20 +0200 Daily Problem Diffstat:
A | Problems/0744.cpp | | | 18 | ++++++++++++++++++ |
M | README.md | | | 1 | + |
2 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/Problems/0744.cpp b/Problems/0744.cpp @@ -0,0 +1,18 @@ +class Solution { +public: + char nextGreatestLetter(vector<char> &letters, char target) { + if (target >= letters.back()) return letters.front(); + int low = 0, high = letters.size() - 1; + target++; + while (low < high) { + int mid = low + (high - low) / 2; + if (letters[mid] == target) + return letters[mid]; + else if (letters[mid] < target) + low = mid + 1; + else + high = mid; + } + return letters[high]; + } +}; diff --git a/README.md b/README.md @@ -338,6 +338,7 @@ for solving problems. | 0739 | Medium | [Daily Temperatures](Problems/0739.cpp) | | 0740 | Medium | [Delete and Earn](Problems/0740.cpp) | | 0743 | Medium | [Network Delay Time](Problems/0743.cpp) | +| 0744 | Easy | [Find Smallest Letter Greater Than Target](Problems/0744.cpp) | | 0746 | Easy | [Min Cost Climbing Stairs](Problems/0746.cpp) | | 0747 | Easy | [Largest Number At Least Twice of Others](Problems/0747.cpp) | | 0752 | Medium | [Open the Lock](Problems/0752.cpp) |