add: descriptions
This commit is contained in:
parent
41677cc3df
commit
8a7e8c00e8
|
|
@ -1,10 +1,14 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <queue>
|
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 {
|
class Solution {
|
||||||
private:
|
private:
|
||||||
// Interval [L, R)
|
// Interval [L, R)
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,13 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 {
|
class Solution {
|
||||||
private:
|
private:
|
||||||
static std::unordered_map<std::string, int> breakWords(const std::string& s) {
|
static std::unordered_map<std::string, int> breakWords(const std::string& s) {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,16 @@
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 {
|
class Solution {
|
||||||
public:
|
public:
|
||||||
static void rotate(std::vector<int>& nums, int k) {
|
static void rotate(std::vector<int>& nums, int k) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,11 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 {
|
class Solution {
|
||||||
public:
|
public:
|
||||||
static constexpr int numberOfSteps(int num) {
|
static constexpr int numberOfSteps(int num) {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,12 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 {
|
class Solution {
|
||||||
public:
|
public:
|
||||||
static int maximumWealth(const std::vector<std::vector<int>>& accounts) {
|
static int maximumWealth(const std::vector<std::vector<int>>& accounts) {
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,12 @@
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 {
|
class Solution {
|
||||||
private:
|
private:
|
||||||
static bool isNice(const std::string& str, int L, int R) {
|
static bool isNice(const std::string& str, int L, int R) {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,13 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 {
|
class Solution {
|
||||||
public:
|
public:
|
||||||
static int maxProfit(const std::vector<int>& prices) {
|
static int maxProfit(const std::vector<int>& prices) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue