go: add «1460. Make Two Arrays Equal by Reversing Subarrays»
Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
parent
79db7a329c
commit
ef40cbb1fd
1 changed files with 16 additions and 0 deletions
16
go/make-two-arrays-equal-by-reversing-subarrays.go
Normal file
16
go/make-two-arrays-equal-by-reversing-subarrays.go
Normal file
|
@ -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
|
||||||
|
}
|
Loading…
Reference in a new issue