Skip to content

Commit f277f53

Browse files
committed
update typo
1 parent dc5885d commit f277f53

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "algorithms-rs"
3-
version = "0.1.10"
3+
version = "0.1.11"
44
authors = ["davirain <davirian.yin@gmail.com>"]
55
categories = ["algorithms"]
66
documentation = "https://docs.rs/algorithms-rs"

rust/src/chapter4/find_maximum_subarray.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ where
4141
(max_left, max_right, left_sum + right_sum)
4242
}
4343

44-
pub fn find_maximum_suarray<T>(array: &[T], low: usize, hight: usize) -> (usize, usize, T)
44+
/// find maximum sub array
45+
pub fn find_maximum_subarray<T>(array: &[T], low: usize, hight: usize) -> (usize, usize, T)
4546
where
4647
T: Zero + Bounded + AddAssign + PartialOrd + Default + Clone + Copy + Debug,
4748
{
@@ -51,8 +52,8 @@ where
5152
} else {
5253
let mid = ((low as f64 + hight as f64) / 2f64).floor() as usize;
5354

54-
let (left_low, left_heigh, left_sum) = find_maximum_suarray(array, low, mid);
55-
let (right_low, right_high, right_sum) = find_maximum_suarray(array, mid + 1, hight);
55+
let (left_low, left_heigh, left_sum) = find_maximum_subarray(array, low, mid);
56+
let (right_low, right_high, right_sum) = find_maximum_subarray(array, mid + 1, hight);
5657
let (cross_low, cross_hight, cross_sum) =
5758
find_max_crossing_subarray(array, low, mid, hight);
5859

@@ -67,9 +68,9 @@ where
6768
}
6869

6970
#[test]
70-
fn test_find_maximum_suarray() {
71+
fn test_find_maximum_subarray() {
7172
let array = vec![-2, 1, -3, 4, -1, 2, 1, -5, 4];
72-
let result = find_maximum_suarray(&array, 0, array.len() - 1);
73+
let result = find_maximum_subarray(&array, 0, array.len() - 1);
7374
println!(
7475
"start is {}, end is {}, sum is {}",
7576
result.0, result.1, result.2

0 commit comments

Comments
 (0)