Skip to content

Commit

Permalink
add sol
Browse files Browse the repository at this point in the history
  • Loading branch information
ductnn committed Dec 10, 2023
1 parent 53d87c1 commit 41074e4
Showing 1 changed file with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package main

import (
"fmt"
)

func findDifference(nums1 []int, nums2 []int) [][]int {
s1, s2 := make(map[int]bool), make(map[int]bool)
for _, v := range nums1 {
s1[v] = true
}
for _, v := range nums2 {
s2[v] = true
}
result := make([][]int, 2)
for v := range s1 {
if !s2[v] {
result[0] = append(result[0], v)
}
}
for v := range s2 {
if !s1[v] {
result[1] = append(result[1], v)
}
}
return result
}

func main() {
nums1 := []int{1, 2, 3}
nums2 := []int{2, 4, 6}
fmt.Println(findDifference(nums1, nums2))
}

0 comments on commit 41074e4

Please sign in to comment.