Skip to content

Commit

Permalink
docs(canjump) improve readme
Browse files Browse the repository at this point in the history
  • Loading branch information
MSilva95 committed May 8, 2024
1 parent 53f8044 commit cb54c23
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions subjects/canjump/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,37 @@
## Can Jump

Given an array of non-negative integers representing the maximum number of steps you can take forward from each position, implement the function `CanJump()` which takes a `[]uint` as input and returns a `boolean` value to determine if it's possible to reach the last index starting from the first index based on these maximum steps. The function should return `true` if it's possible to reach and stay at the last index without stepping out of the array and `false` otherwise.
Given an array of non-negative integers representing the number of steps you can take forward from each position, implement the function `CanJump()` which takes a slice of unsigned integers `[]uint` as input and returns a `boolean` value. This function should determine if it's possible to reach and stay at the last index of the array starting from the first index, based on the steps you need to advance. Be aware that:

> Note: Remember, if the input has only one element, that is the last position in the array so the function will return `true` but if the array is empty it returns `false`.
- Each value represents the exact number of steps you must take forward from that position.
- The function should return `true` if it's possible to reach and stay at the last index without stepping out of the array, and `false` otherwise.
- If the input has only one element, that is the last position in the array so the function will return `true` but if the array is empty it returns `false`.

Let's take the example array input := []uint{2, 3, 1, 1, 4}.

```console

Position: 0 1 2 3 4
Steps: 2 3 1 1 4
^

// Starting from position 0, you have 2 steps to move forward. This means you will move to positions 2.

Position: 0 1 2 3 4
Steps: 2 3 1 1 4
^

// From position 2, you have 1 step, so you will move to position 3.

Position: 0 1 2 3 4
Steps: 2 3 1 1 4
^

// Finally, from position 3, you have 1 step to reach the last index at position 4 confirming that it's possible so the output will be "True".

Position: 0 1 2 3 4
Steps: 2 3 1 1 4
^
```

### Usage

Expand Down

0 comments on commit cb54c23

Please sign in to comment.