between-us 1.0.0

Finds two most distant smaller and bigger numbers.
Documentation
  • Coverage
  • 33.33%
    1 out of 3 items documented1 out of 1 items with examples
  • Size
  • Source code size: 5.3 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.05 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • inoshy tausifcreates

Far across the distance, And spaces, between us 🎵

Functionality

Finds the maximmum right - left, such that list[right] > list[left].

Time Complexity : O(n) (2 traversals)

Space Complexity : O(n) (1 extra list)

How to use

The find_distance function takes a ref to an array or a vector as a paramaeter, and finds the maximum distance of two such elements.

It returns an Option<usize> type as a result, because two such numbers that satisfy the condition might not exist. In that case, it returns None.

Quick Start:

use between_us::interface::find_distance;

fn main() {
	let list = [5, 3, 7, 1, 6, 8, 4];

	let result = find_distance(&list);

	println!("{:?}", result);

	// Output: Some(5)
}