Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import "fmt"
- func solve(slice [] int) [] int {
- lx := [] int {}
- rx := [] int {}
- for index := 0 ; index < len(slice) ; index++ {
- if index == 0 {
- lx[index] = 1
- } else {
- lx[index] = slice[index-1] * lx[index-1]
- }
- }
- for index := len(slice) ; index > 0 ; index-- {
- if index == len(slice)-1 {
- rx[index] = 1
- } else {
- rx[index] = slice[index+1] * rx[index+1]
- }
- }
- for i,_ := range(slice){
- slice[i] = lx[i] * rx[i]
- }
- return slice
- }
- func main(){
- p := [] int {1,2}
- k := solve(p)
- for _,el := range(k){
- fmt.Println(el)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement