Solved: 30 - Sort and Find
This commit is contained in:
@@ -1,9 +1,19 @@
|
|||||||
#include "sort_and_find.hpp"
|
#include "sort_and_find.hpp"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
namespace stl_algorithms {
|
namespace stl_algorithms {
|
||||||
|
|
||||||
auto sorted_copy(std::vector<int> data) -> std::vector<int> { (void)data; return {}; }
|
auto sorted_copy(std::vector<int> data) -> std::vector<int> {
|
||||||
auto contains(const std::vector<int>& data, int value) -> bool { (void)data; (void)value; return false; }
|
std::ranges::sort(data);
|
||||||
auto lower_bound_index(const std::vector<int>& sorted, int value) -> int { (void)sorted; (void)value; return -1; }
|
return data;
|
||||||
|
}
|
||||||
|
auto contains(const std::vector<int>& data, const int value) -> bool {
|
||||||
|
return std::ranges::find(data, value) != data.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto lower_bound_index(const std::vector<int>& sorted, const int value) -> int {
|
||||||
|
return static_cast<int>(std::ranges::lower_bound(sorted, value) - sorted.begin());
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace stl_algorithms
|
} // namespace stl_algorithms
|
||||||
|
|||||||
Reference in New Issue
Block a user