add: descriptions
This commit is contained in:
parent
7849945eee
commit
e28411d091
|
|
@ -1,6 +1,13 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 2000. Reverse Prefix of Word
|
||||||
|
* Given a 0-indexed string word and a character ch, reverse the segment of word that starts at index 0 and ends at the index of the first occurrence of ch (inclusive). If the character ch does not exist in word, do nothing.
|
||||||
|
* For example, if word = "abcdefd" and ch = "d", then you should reverse the segment that starts at 0 and ends at 3 (inclusive). The resulting string will be "dcbaefd".
|
||||||
|
* Return the resulting string.
|
||||||
|
*/
|
||||||
|
|
||||||
class Solution {
|
class Solution {
|
||||||
public:
|
public:
|
||||||
static std::string reversePrefix(std::string word, char ch) {
|
static std::string reversePrefix(std::string word, char ch) {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,12 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 438. Find All Anagrams in a String
|
||||||
|
* Given two strings s and p, return an array of all the start indices of p's anagrams in s. You may return the answer in any order.
|
||||||
|
* An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.
|
||||||
|
*/
|
||||||
|
|
||||||
class Solution {
|
class Solution {
|
||||||
private:
|
private:
|
||||||
template<int N>
|
template<int N>
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,18 @@
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 1414. Find the Minimum Number of Fibonacci Numbers Whose Sum Is K
|
||||||
|
* Given an integer k, return the minimum number of Fibonacci numbers whose sum is equal to k. The same Fibonacci number can be used multiple times.
|
||||||
|
*
|
||||||
|
* The Fibonacci numbers are defined as:
|
||||||
|
*
|
||||||
|
* F[1] = 1
|
||||||
|
* F[2] = 1
|
||||||
|
* F[n] = F[n-1] + F[n-2] for n > 2.
|
||||||
|
* It is guaranteed that for the given constraints we can always find such Fibonacci numbers that sum up to k.
|
||||||
|
*/
|
||||||
|
|
||||||
class Solution {
|
class Solution {
|
||||||
private:
|
private:
|
||||||
inline static constexpr int fib[] = {1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418, 317811, 514229, 832040, 1346269, 2178309, 3524578, 5702887, 9227465, 14930352, 24157817, 39088169, 63245986, 102334155, 165580141, 267914296, 433494437, 701408733, 1134903170, 1836311903};
|
inline static constexpr int fib[] = {1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418, 317811, 514229, 832040, 1346269, 2178309, 3524578, 5702887, 9227465, 14930352, 24157817, 39088169, 63245986, 102334155, 165580141, 267914296, 433494437, 701408733, 1134903170, 1836311903};
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,13 @@
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 454. 4Sum II
|
||||||
|
* Given four integer arrays nums1, nums2, nums3, and nums4 all of length n, return the number of tuples (i, j, k, l) such that:
|
||||||
|
* 0 <= i, j, k, l < n
|
||||||
|
* nums1[i] + nums2[j] + nums3[k] + nums4[l] == 0
|
||||||
|
*/
|
||||||
|
|
||||||
class Solution {
|
class Solution {
|
||||||
public:
|
public:
|
||||||
static int fourSumCount(const std::vector<int>& nums1, const std::vector<int>& nums2, const std::vector<int>& nums3, const std::vector<int>& nums4) {
|
static int fourSumCount(const std::vector<int>& nums1, const std::vector<int>& nums2, const std::vector<int>& nums3, const std::vector<int>& nums4) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue