add: DESCRIPTIONS

This commit is contained in:
Lam Haoyin 2022-03-07 08:15:34 +08:00
parent 6cfc7529fd
commit 4a761f21c6
No known key found for this signature in database
GPG Key ID: 8C089CB1A2B7544F
3 changed files with 26 additions and 0 deletions

View File

@ -1,6 +1,14 @@
#include <string> #include <string>
#include <iostream> #include <iostream>
/**
* 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 { class Solution {
public: public:
// clang does not accept constexpr // clang does not accept constexpr

View File

@ -1,6 +1,17 @@
#include <vector> #include <vector>
#include <iostream> #include <iostream>
/**
* 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 { class Solution {
public: public:
static std::vector<int> goodDaysToRobBank(const std::vector<int>& security, int time) { static std::vector<int> goodDaysToRobBank(const std::vector<int>& security, int time) {

View File

@ -1,5 +1,12 @@
#include <iostream> #include <iostream>
/**
* 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 { class Solution {
private: private:
inline static const int MOD = 1000000007; inline static const int MOD = 1000000007;