ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
SequenceProblems.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/*------------------------ File SequenceProblems.h -------------------------*/
3/*--------------------------------------------------------------------------*/
62/*--------------------------------------------------------------------------*/
63/*----------------------------- DEFINITIONS --------------------------------*/
64/*--------------------------------------------------------------------------*/
65
66#ifndef __ADS_SequenceProblems
67 #define __ADS_SequenceProblems
68/* self-identification: #endif constant */
69
70/*--------------------------------------------------------------------------*/
71/*------------------------------ INCLUDES ----------------------------------*/
72/*--------------------------------------------------------------------------*/
73
74#include "ADS/Contract.h"
75
76#include <algorithm>
77#include <concepts>
78#include <cstddef>
79#include <functional>
80#include <unordered_map>
81#include <utility>
82#include <vector>
83
84/*--------------------------------------------------------------------------*/
85/*--------------------------- NAMESPACE ------------------------------------*/
86/*--------------------------------------------------------------------------*/
87
88namespace ADS
89{
90
113template< class T >
114T trappingRainWater( const std::vector< T > & h );
115
140template< std::integral T >
141std::vector< T > largestDivisibleSubset( std::vector< T > A );
142
165template< class T >
166T maxSumIncreasingSubsequence( const std::vector< T > & A );
167
188template< class T , class Less >
189std::vector< std::size_t > longestChainSubsequence( const std::vector< T > & S ,
190 Less less );
191
214template< class T , class Hash = std::hash< T > >
215std::pair< std::size_t , std::size_t >
216longestDistinctSegment( const std::vector< T > & A );
217
218/*--------------------------------------------------------------------------*/
219
220} // end( namespace ADS )
221
222/*--------------------------------------------------------------------------*/
223/*-------------------------- IMPLEMENTATION --------------------------------*/
224/*--------------------------------------------------------------------------*/
225
226#include "ADS/optimization/impl/SequenceProblems.tpp"
227
228/*--------------------------------------------------------------------------*/
229
230#endif /* SequenceProblems.h included */
231
232/*--------------------------------------------------------------------------*/
233/*---------------------- End File SequenceProblems.h -----------------------*/
234/*--------------------------------------------------------------------------*/
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
T maxSumIncreasingSubsequence(const std::vector< T > &A)
the largest sum of a strictly increasing subsequence of , 0 for the empty one
std::vector< T > largestDivisibleSubset(std::vector< T > A)
a largest subset of in which of any two items one divides the other, sorted
std::vector< std::size_t > longestChainSubsequence(const std::vector< T > &S, Less less)
the places of a longest subsequence of each item of which precedes the next by less,...
T trappingRainWater(const std::vector< T > &h)
the water held by the columns of heights , no walls outside
std::pair< std::size_t, std::size_t > longestDistinctSegment(const std::vector< T > &A)
the start and the length of the first longest segment of with no value repeated
Definition ADT.h:96