ADS
Algorithms and Data Structures
Toggle main menu visibility
Loading...
Searching...
No Matches
StockTrading.h
Go to the documentation of this file.
1
/*--------------------------------------------------------------------------*/
2
/*-------------------------- File StockTrading.h ---------------------------*/
3
/*--------------------------------------------------------------------------*/
46
/*--------------------------------------------------------------------------*/
47
/*----------------------------- DEFINITIONS --------------------------------*/
48
/*--------------------------------------------------------------------------*/
49
50
#ifndef __ADS_StockTrading
51
#define __ADS_StockTrading
52
/* self-identification: #endif constant */
53
54
/*--------------------------------------------------------------------------*/
55
/*------------------------------ INCLUDES ----------------------------------*/
56
/*--------------------------------------------------------------------------*/
57
58
#include "
ADS/Contract.h
"
59
60
#include <algorithm>
61
#include <cstddef>
62
#include <optional>
63
#include <vector>
64
65
/*--------------------------------------------------------------------------*/
66
/*--------------------------- NAMESPACE ------------------------------------*/
67
/*--------------------------------------------------------------------------*/
68
69
namespace
ADS
70
{
71
94
template
<
class
T >
95
T
maxProfit
(
const
std::vector< T > & prices , std::size_t k );
96
111
template
<
class
T >
112
std::optional< T >
maxProfitExactly
(
const
std::vector< T > & prices ,
113
std::size_t k );
114
115
/*--------------------------------------------------------------------------*/
116
117
}
// end( namespace ADS )
118
119
/*--------------------------------------------------------------------------*/
120
/*-------------------------- IMPLEMENTATION --------------------------------*/
121
/*--------------------------------------------------------------------------*/
122
123
#include "ADS/optimization/impl/StockTrading.tpp"
124
125
/*--------------------------------------------------------------------------*/
126
127
#endif
/* StockTrading.h included */
128
129
/*--------------------------------------------------------------------------*/
130
/*------------------------ End File StockTrading.h -------------------------*/
131
/*--------------------------------------------------------------------------*/
Contract.h
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
ADS::maxProfit
T maxProfit(const std::vector< T > &prices, std::size_t k)
the largest gain of at most transactions on the prices
ADS::maxProfitExactly
std::optional< T > maxProfitExactly(const std::vector< T > &prices, std::size_t k)
the largest gain of exactly transactions on the prices, nothing if there are fewer than days
ADS
Definition
ADT.h:96
ADS
optimization
StockTrading.h
Generated by
1.17.0