Skip to content

Commit ea02477

Browse files
3668
1 parent cb910d0 commit ea02477

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
class Solution
3+
{
4+
/**
5+
* @param Integer[] $order
6+
* @param Integer[] $friends
7+
* @return Integer[]
8+
*/
9+
public function recoverOrder($order, $friends)
10+
{
11+
$friendFlip = array_flip($friends);
12+
13+
$result = [];
14+
15+
foreach ($order as $value) {
16+
if (isset($friendFlip[$value])) {
17+
$result[] = $value;
18+
}
19+
}
20+
return $result;
21+
}
22+
}

0 commit comments

Comments
 (0)