From ef40cbb1fd1befd0c972377e3b15531aadabd029 Mon Sep 17 00:00:00 2001 From: Matej Focko Date: Sat, 3 Aug 2024 17:47:12 +0200 Subject: [PATCH] =?UTF-8?q?go:=20add=20=C2=AB1460.=20Make=20Two=20Arrays?= =?UTF-8?q?=20Equal=20by=20Reversing=20Subarrays=C2=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Matej Focko --- ...ke-two-arrays-equal-by-reversing-subarrays.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 go/make-two-arrays-equal-by-reversing-subarrays.go diff --git a/go/make-two-arrays-equal-by-reversing-subarrays.go b/go/make-two-arrays-equal-by-reversing-subarrays.go new file mode 100644 index 0000000..38ce7e7 --- /dev/null +++ b/go/make-two-arrays-equal-by-reversing-subarrays.go @@ -0,0 +1,16 @@ +package main + +import "slices" + +func canBeEqual(target []int, arr []int) bool { + slices.Sort(target) + slices.Sort(arr) + + for i := range target { + if arr[i] != target[i] { + return false + } + } + + return true +}