Last active
March 1, 2021 13:48
-
-
Save alexcpn/bd8aa04d85470734fba79a74a0850902 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// in := [][]int{{}} in := [][]int{{1,3},{2,3}} | |
// addtoEndofSliceArray(in,1) | |
// out=[[1]] out=[[1,3],[2,3,1]] | |
func addtoEndofSliceArray(in [][]int,element int)(out [][]int){ | |
if len(in) >0 { | |
k :=in[len(in)-1] | |
k = append(k,element) | |
in = in[:len(in)-1] | |
in = append(in, k) | |
}else{ | |
in = [][]int{{element}} | |
} | |
return in | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment