I think this problem is not very hard and it's interesting.↵
↵
Description:↵
↵
``↵
↵
You are given $2$ arrays $a$ and $b$ and the length of them is $n$.↵
↵
- $1$, $3$, $5$, ......, $2 * n - 1$ is in $a$.↵
↵
- $2$, $4$, $6$, ......, $2 * n$ is in $b$.↵
↵
$\mathrm{Algorithm}\ 1:$↵
↵
we use the array $mp_i$ is $i$ the distance to the $a_1$ or $b_1$.↵
↵
We can enumerate the $i$ and the $j$, and the answer is $$↵
↵
Description:↵
↵
↵
↵
- $1$, $3$, $5$, ......, $2 * n - 1$ is in $a$.↵
↵
- $2$, $4$, $6$, ......, $2 * n$ is in $b$.↵
↵
$\mathrm{Algorithm}\ 1:$↵
↵
we use the array $mp_i$ is $i$ the distance to the $a_1$ or $b_1$.↵
↵
We can enumerate the $i$ and the $j$, and the answer is $$↵