mirror of
https://github.com/lukefleed/competitive-programming.git
synced 2026-10-06 14:14:52 +00:00
fixed readmes
This commit is contained in:
@@ -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
|
||||
fn leaders_in_an_array(arr: &[i32]) -> Vec<i32> {
|
||||
|
||||
@@ -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.
|
||||
|
||||
### Complexity
|
||||
|
||||
### Coding
|
||||
- **Time Complexity:** `O(n)` `
|
||||
- **Space Complexity:** `O(1)`
|
||||
|
||||
---
|
||||
|
||||
### Solution in Rust
|
||||
```rust
|
||||
fn max_sub_array(nums: &[i32]) -> i32 {
|
||||
let mut max_ending_here = nums[0];
|
||||
|
||||
@@ -17,6 +17,6 @@ fn max_sub_array(nums: &[i32]) -> i32 {
|
||||
|
||||
fn main() {
|
||||
let nums = [-2, 1, -3, 4, -1, 2, 1, -5, 4];
|
||||
let res = maxSubArray(&nums);
|
||||
let res = max_sub_array(&nums);
|
||||
println!("{}", res);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user