1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//! ✌️ Two Sum Using Set (Generic, Hashable, Additive)
//!
//! Returns true if there exist two distinct elements in the slice whose sum equals the target.
//!
//! # Type Parameters
//! * `T`: The element type. Must implement `Eq` + `Hash` + `Copy` + `Sub<Output = T>` + `Add<Output = T>` + `PartialEq`.
//!
//! # Arguments
//! * `slice` - The slice to search.
//! * `target` - The target sum.
//!
//! # Returns
//! * `bool` - True if such a pair exists, false otherwise.
//!
//! # Example
//! ```rust
//! use pofk_algorithm::set_algorithms::has_two_sum::has_two_sum;
//! let arr = [1, 2, 3, 4];
//! assert!(has_two_sum(&arr, 5));
//! assert!(!has_two_sum(&arr, 10));
//! ```
use HashSet;
use Sub;