Skip to content

Commit 25b1519

Browse files
committed
feat: add js solution to lc problem: No.1460
1 parent aa8e3b1 commit 25b1519

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

solution/1400-1499/1460.Make Two Arrays Equal by Reversing Subarrays/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,16 @@ function canBeEqual(target: number[], arr: number[]): boolean {
134134
}
135135
```
136136

137+
#### JavaScript
138+
139+
```js
140+
function canBeEqual(target, arr) {
141+
target.sort();
142+
arr.sort();
143+
return target.every((x, i) => x === arr[i]);
144+
}
145+
```
146+
137147
#### Rust
138148

139149
```rust

solution/1400-1499/1460.Make Two Arrays Equal by Reversing Subarrays/README_EN.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,16 @@ function canBeEqual(target: number[], arr: number[]): boolean {
132132
}
133133
```
134134

135+
#### JavaScript
136+
137+
```js
138+
function canBeEqual(target, arr) {
139+
target.sort();
140+
arr.sort();
141+
return target.every((x, i) => x === arr[i]);
142+
}
143+
```
144+
135145
#### Rust
136146

137147
```rust
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function canBeEqual(target, arr) {
2+
target.sort();
3+
arr.sort();
4+
return target.every((x, i) => x === arr[i]);
5+
}

0 commit comments

Comments
 (0)