algo — C++23 日本語リファレンス GitHub

intersection

関数 · 区間演算

// (1)
template <std::integral T>
std::optional<std::pair<T, T>> intersection(T l1, T r1, T l2, T r2);

// (2)
template <std::integral T>
std::optional<std::pair<T, T>> intersection(std::pair<T, T> a, std::pair<T, T> b);

概要

2つの半開区間の共通部分を返し、交差しなければ std::nullopt を返す

計算量

関連項目