fixed readmes

This commit is contained in:
Luca Lombardo
2023-09-26 15:13:05 +02:00
parent b8a53afc00
commit c8c16c450d
3 changed files with 9 additions and 3 deletions
+1 -1
View File
@@ -11,7 +11,7 @@ So after we have iterated through all the array, we can reverse the list and ret
--- ---
### Rust solution ### Solution in Rust
```rust ```rust
fn leaders_in_an_array(arr: &[i32]) -> Vec<i32> { fn leaders_in_an_array(arr: &[i32]) -> Vec<i32> {
+7 -1
View File
@@ -6,8 +6,14 @@ At each index, the algorithm compares the current element with the maximum sum e
The algorithm also keeps track of the maximum sum seen so far, which is the maximum of all the maximum sums ending at each index. The final result is the maximum sum seen so far. The algorithm also keeps track of the maximum sum seen so far, which is the maximum of all the maximum sums ending at each index. The final result is the maximum sum seen so far.
### Complexity
### Coding - **Time Complexity:** `O(n)` `
- **Space Complexity:** `O(1)`
---
### Solution in Rust
```rust ```rust
fn max_sub_array(nums: &[i32]) -> i32 { fn max_sub_array(nums: &[i32]) -> i32 {
let mut max_ending_here = nums[0]; let mut max_ending_here = nums[0];
+1 -1
View File
@@ -17,6 +17,6 @@ fn max_sub_array(nums: &[i32]) -> i32 {
fn main() { fn main() {
let nums = [-2, 1, -3, 4, -1, 2, 1, -5, 4]; let nums = [-2, 1, -3, 4, -1, 2, 1, -5, 4];
let res = maxSubArray(&nums); let res = max_sub_array(&nums);
println!("{}", res); println!("{}", res);
} }