mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
628 B
39 lines
628 B
5 years ago
|
## doppelganger
|
||
|
|
||
|
### Instructions
|
||
|
|
||
|
You are given 2 strings. Find out if first string contains second string. If it does, return index of the first string where second string occurs last time. If it does not contain, return "-1"
|
||
|
|
||
|
### Expected function
|
||
|
|
||
|
```go
|
||
|
package main
|
||
|
|
||
5 years ago
|
func DoppelGanger(s, substr string) int {
|
||
5 years ago
|
|
||
|
}
|
||
|
```
|
||
|
|
||
|
```go
|
||
|
package main
|
||
|
|
||
5 years ago
|
import (
|
||
|
"fmt"
|
||
5 years ago
|
|
||
|
piscine ".."
|
||
5 years ago
|
)
|
||
5 years ago
|
|
||
|
func main() {
|
||
|
var result int
|
||
|
|
||
5 years ago
|
result = piscine.DoppelGanger("aaaaaaa", "a")
|
||
5 years ago
|
fmt.Println(result) // 6
|
||
|
|
||
5 years ago
|
result = piscine.DoppelGanger("qwerty", "t")
|
||
5 years ago
|
fmt.Println(result) // 4
|
||
|
|
||
5 years ago
|
result = piscine.DoppelGanger("a", "b")
|
||
5 years ago
|
fmt.Println(result) // -1
|
||
|
}
|
||
|
```
|