forked from root/public
Compare commits
3 Commits
master
...
1164-findm
Author | SHA1 | Date |
---|---|---|
Hamza elkhatri | 0774ca3846 | 2 years ago |
Hamza elkhatri | c35c939d84 | 2 years ago |
hamza | af089f969e | 2 years ago |
1 changed files with 40 additions and 0 deletions
@ -0,0 +1,40 @@
|
||||
## find-missing-number |
||||
|
||||
### Instructions |
||||
|
||||
Write a function that takes an array of numbers and returns the missing number. |
||||
- If the array is empty, return `-1`. |
||||
- If the array contains only one number or there is no missing number, return `-1`. |
||||
- if the array contains more than one missing number, return the minimum missing number. |
||||
|
||||
### Expected function |
||||
```go |
||||
func FindMissingNumber(numbers []int) int { |
||||
// Your code here |
||||
} |
||||
``` |
||||
|
||||
### Usage |
||||
|
||||
Here is a possible program to test your function: |
||||
|
||||
```go |
||||
package main |
||||
|
||||
import "fmt" |
||||
|
||||
func main(){ |
||||
fmt.Println(FindMissingNumber([]int{1, 2, 5,3, 6, 7, 8, 9, 10})) |
||||
fmt.Println(FindMissingNumber([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11})) |
||||
fmt.Println(FindMissingNumber([]int{-10,12,32}) |
||||
} |
||||
``` |
||||
|
||||
and the output should be: |
||||
|
||||
```console |
||||
$ go run . |
||||
4 |
||||
-1 |
||||
-9 |
||||
``` |
Loading…
Reference in new issue