func nextGreaterElement(nums1 []int, nums2 []int) []int {
var ans []int
for _, n := range nums1 {
f := false
g := -1
for _, v := range nums2 {
if f && v > n {
g = v
break
}
if n == v {
f = true
}
}
ans = append(ans, g)
}
return ans
}