chore: big refactor
This commit is contained in:
parent
586ed15310
commit
e4093d32fd
|
|
@ -4,4 +4,6 @@ PROJECT(2305)
|
|||
SET(CMAKE_CXX_STANDARD 23)
|
||||
SET(CMAKE_EXPORT_COMPILE_COMMANDS true)
|
||||
|
||||
ADD_EXECUTABLE(2305 230501.cpp)
|
||||
FILE(GLOB src *.cpp)
|
||||
|
||||
ADD_EXECUTABLE(2305 ${src})
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@
|
|||
* Return the average salary of employees excluding the minimum and maximum salary. Answers within 1e-5 of the actual answer will be accepted.
|
||||
*/
|
||||
|
||||
class Solution {
|
||||
class LC230501 {
|
||||
public:
|
||||
static inline double average(const std::vector<int>&) noexcept;
|
||||
static double average(const std::vector<int>&) noexcept;
|
||||
};
|
||||
|
||||
inline double Solution::average(const std::vector<int>& salary) noexcept {
|
||||
double LC230501::average(const std::vector<int>& salary) noexcept {
|
||||
return (
|
||||
std::reduce(salary.begin(), salary.end(), 0.0) -
|
||||
*std::min_element(salary.begin(), salary.end()) -
|
||||
|
|
@ -13,13 +13,13 @@
|
|||
* Return the number of minutes needed to inform all the employees about the urgent news.
|
||||
*/
|
||||
|
||||
class Solution {
|
||||
class LC230501CN {
|
||||
public:
|
||||
using CVIR = const std::vector<int>&;
|
||||
static int numOfMinutes(int, int, CVIR, CVIR);
|
||||
};
|
||||
|
||||
int Solution::numOfMinutes(int n, int headID, CVIR manager, CVIR informTime) {
|
||||
int LC230501CN::numOfMinutes(int n, int headID, CVIR manager, CVIR informTime) {
|
||||
std::vector<int> ans(n, -1);
|
||||
ans[headID] = 0;
|
||||
std::function<int(int)> dp = [&](int cur) {
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
#ifndef LEETCODE_CPP_DEFS_H
|
||||
#define LEETCODE_CPP_DEFS_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
class LC230501CN {
|
||||
public:
|
||||
using CVIR = const std::vector<int>&;
|
||||
static int numOfMinutes(int, int, CVIR, CVIR);
|
||||
};
|
||||
|
||||
class LC230501 {
|
||||
public:
|
||||
static double average(const std::vector<int>&) noexcept;
|
||||
};
|
||||
|
||||
#endif //LEETCODE_CPP_DEFS_H
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
#include <iostream>
|
||||
|
||||
#include "defs.h"
|
||||
|
||||
int main() {
|
||||
std::cout << LC230501::average({1, 2, 3, 4}) << std::endl;
|
||||
std::cout << LC230501CN::numOfMinutes(1, 0, {-1}, {0}) << std::endl;
|
||||
return 0;
|
||||
}
|
||||
Loading…
Reference in New Issue