From 4a761f21c621b8f2c59f16bd89748576bca28d32 Mon Sep 17 00:00:00 2001 From: Lam Haoyin Date: Mon, 7 Mar 2022 08:15:34 +0800 Subject: [PATCH] add: DESCRIPTIONS --- cpp/2203/220305-CN.cpp | 8 ++++++++ cpp/2203/220306-CN.cpp | 11 +++++++++++ cpp/2203/220306.cpp | 7 +++++++ 3 files changed, 26 insertions(+) diff --git a/cpp/2203/220305-CN.cpp b/cpp/2203/220305-CN.cpp index 03666f0..f39831e 100644 --- a/cpp/2203/220305-CN.cpp +++ b/cpp/2203/220305-CN.cpp @@ -1,6 +1,14 @@ #include #include +/** + * 521. Longest Uncommon Subsequence I + * Given two strings a and b, return the length of the longest uncommon subsequence between a and b. If the longest uncommon subsequence does not exist, return -1. + * An uncommon subsequence between two strings is a string that is a subsequence of one but not the other. + * A subsequence of a string s is a string that can be obtained after deleting any number of characters from s. + * For example, "abc" is a subsequence of "aebdc" because you can delete the underlined characters in "aebdc" to get "abc". Other subsequences of "aebdc" include "aebdc", "aeb", and "" (empty string). + */ + class Solution { public: // clang does not accept constexpr diff --git a/cpp/2203/220306-CN.cpp b/cpp/2203/220306-CN.cpp index 56fcff3..b8b098f 100644 --- a/cpp/2203/220306-CN.cpp +++ b/cpp/2203/220306-CN.cpp @@ -1,6 +1,17 @@ #include #include +/** + * 2100. Find Good Days to Rob the Bank + * You and a gang of thieves are planning on robbing a bank. You are given a 0-indexed integer array security, where security[i] is the number of guards on duty on the ith day. The days are numbered starting from 0. You are also given an integer time. + * The ith day is a good day to rob the bank if: + * There are at least time days before and after the ith day, + * The number of guards at the bank for the time days before i are non-increasing, and + * The number of guards at the bank for the time days after i are non-decreasing. + * More formally, this means day i is a good day to rob the bank if and only if security[i - time] >= security[i - time + 1] >= ... >= security[i] <= ... <= security[i + time - 1] <= security[i + time]. + * Return a list of all days (0-indexed) that are good days to rob the bank. The order that the days are returned in does not matter. + */ + class Solution { public: static std::vector goodDaysToRobBank(const std::vector& security, int time) { diff --git a/cpp/2203/220306.cpp b/cpp/2203/220306.cpp index 670dff7..23160db 100644 --- a/cpp/2203/220306.cpp +++ b/cpp/2203/220306.cpp @@ -1,5 +1,12 @@ #include +/** + * 1359. Count All Valid Pickup and Delivery Options + * Given n orders, each order consist in pickup and delivery services. + * Count all valid pickup/delivery possible sequences such that delivery(i) is always after of pickup(i). + * Since the answer may be too large, return it modulo 10^9 + 7. + */ + class Solution { private: inline static const int MOD = 1000000007;