diff --git a/2201/220129.cpp b/2201/220129.cpp index b3f084f..14b0131 100644 --- a/2201/220129.cpp +++ b/2201/220129.cpp @@ -1,10 +1,14 @@ #include #include #include -#include #include #include +/** + * 84. Largest Rectangle in Histogram + * Given an array of integers heights representing the histogram's bar height where the width of each bar is 1, return the area of the largest rectangle in the histogram. + */ + class Solution { private: // Interval [L, R) diff --git a/2201/220130-CN.cpp b/2201/220130-CN.cpp index 75c88fa..3074488 100644 --- a/2201/220130-CN.cpp +++ b/2201/220130-CN.cpp @@ -2,6 +2,13 @@ #include #include +/** + * 884. Uncommon Words from Two Sentences + * A sentence is a string of single-space separated words where each word consists only of lowercase letters. + * A word is uncommon if it appears exactly once in one of the sentences, and does not appear in the other sentence. + * Given two sentences s1 and s2, return a list of all the uncommon words. You may return the answer in any order. + */ + class Solution { private: static std::unordered_map breakWords(const std::string& s) { diff --git a/2201/220130.cpp b/2201/220130.cpp index 2d61a69..9857f88 100644 --- a/2201/220130.cpp +++ b/2201/220130.cpp @@ -1,6 +1,16 @@ -#include #include +/** + * 189. Rotate Array + * Given an array, rotate the array to the right by k steps, where k is non-negative. + * Input: nums = [1,2,3,4,5,6,7], k = 3 + * Output: [5,6,7,1,2,3,4] + * Explanation: + * rotate 1 steps to the right: [7,1,2,3,4,5,6] + * rotate 2 steps to the right: [6,7,1,2,3,4,5] + * rotate 3 steps to the right: [5,6,7,1,2,3,4] + */ + class Solution { public: static void rotate(std::vector& nums, int k) { diff --git a/2201/220131-CN.cpp b/2201/220131-CN.cpp index d78d59b..442df15 100644 --- a/2201/220131-CN.cpp +++ b/2201/220131-CN.cpp @@ -1,5 +1,11 @@ #include +/** + * 1342. Number of Steps to Reduce a Number to Zero + * Given an integer num, return the number of steps to reduce it to zero. + * In one step, if the current number is even, you have to divide it by 2, otherwise, you have to subtract 1 from it. + */ + class Solution { public: static constexpr int numberOfSteps(int num) { diff --git a/2201/220131.cpp b/2201/220131.cpp index fb9b6e6..ece8827 100644 --- a/2201/220131.cpp +++ b/2201/220131.cpp @@ -1,6 +1,12 @@ #include #include +/** + * 1672. Richest Customer Wealth + * You are given an m x n integer grid accounts where accounts[i][j] is the amount of money the i-th customer has in the j-th bank. Return the wealth that the richest customer has. + * A customer's wealth is the amount of money they have in all their bank accounts. The richest customer is the customer that has the maximum wealth. + */ + class Solution { public: static int maximumWealth(const std::vector>& accounts) { diff --git a/2202/220201-CN.cpp b/2202/220201-CN.cpp index 54214c8..cd9d201 100644 --- a/2202/220201-CN.cpp +++ b/2202/220201-CN.cpp @@ -2,6 +2,12 @@ #include #include +/** + * 1763. Longest Nice Substring + * A string s is nice if, for every letter of the alphabet that s contains, it appears both in uppercase and lowercase. For example, "abABB" is nice because 'A' and 'a' appear, and 'B' and 'b' appear. However, "abA" is not because 'b' appears, but 'B' does not. + * Given a string s, return the longest substring of s that is nice. If there are multiple, return the substring of the earliest occurrence. If there are none, return an empty string. + */ + class Solution { private: static bool isNice(const std::string& str, int L, int R) { diff --git a/2202/220201.cpp b/2202/220201.cpp index 5b2a657..7ff907d 100644 --- a/2202/220201.cpp +++ b/2202/220201.cpp @@ -1,6 +1,13 @@ #include #include +/** + * 121. Best Time to Buy and Sell Stock + * You are given an array prices where prices[i] is the price of a given stock on the ith day. + * You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock. + * Return the maximum profit you can achieve from this transaction. If you cannot achieve any profit, return 0. + */ + class Solution { public: static int maxProfit(const std::vector& prices) {