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