Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1b1135e

Browse files
committed
docs: add jump game problem description
1 parent c8f815b commit 1b1135e

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

‎src/medium/readme.md‎

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,68 @@ Put the code below in main.rs and run `cargo run`
442442
println!("result: {:?}", result);
443443
```
444444

445+
# 53. Maximum Subarray
446+
447+
## Description
448+
449+
Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.
450+
451+
## Examples
452+
453+
```text
454+
Input: [-2,1,-3,4,-1,2,1,-5,4],
455+
Output: 6
456+
457+
Explanation: [4,-1,2,1] has the largest sum = 6.
458+
```
459+
460+
## How to Run in main.rs
461+
462+
Put the code below in main.rs and run `cargo run`
463+
464+
```rust
465+
let nums = vec![-2, 1, -3, 4, -1, 2, 1, -5, 4];
466+
let result = leetcode::medium::maximum_subarray::max_sub_array(nums);
467+
println!("result: {}", result);
468+
```
469+
470+
# 55. Jump Game
471+
472+
## Description
473+
474+
Given an array of non-negative integers, you are initially positioned at the first index of the array.
475+
476+
Each element in the array represents your maximum jump length at that position.
477+
478+
Determine if you are able to reach the last index.
479+
480+
## Examples
481+
482+
```text
483+
Input: [2,3,1,1,4]
484+
Output: true
485+
486+
Explanation: Jump 1 step from index 0 to 1, then 3 steps to the last index.
487+
```
488+
489+
```text
490+
Input: [3,2,1,0,4]
491+
Output: false
492+
493+
Explanation: You will always arrive at index 3 no matter what. Its maximum jump length is 0, which makes it impossible to reach the last index.
494+
```
495+
496+
## How to Run in main.rs
497+
498+
Put the code below in main.rs and run `cargo run`
499+
500+
```rust
501+
let nums = vec![2, 3, 1, 1, 4];
502+
let result = leetcode::medium::jump_game::can_jump(nums);
503+
println!("result: {}", result);
504+
```
505+
506+
445507
# 74. Search a 2D Matrix
446508

447509
## Description

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /