# 第一题

1<= t <= 10

1 <= n <= 10^5

1 <= ai <= 10^9

2

4

1 4 3 2

4

4 3 2 1

YES

NO

### 参考题解

Java：[此代码未进行大量数据的测试，仅供参考]

```import java.util.*;

public class Main {

public static String isPossibleToSort(int n, int[] a) {
if (n % 2 == 1) {
return "YES";
}

List<Integer> b0 = new ArrayList<>();
List<Integer> b1 = new ArrayList<>();
for (int i = 0; i < n; ++i) {
if (i % 2 == 0) {
} else {
}
}

Collections.sort(b0);
Collections.sort(b1);

for (int i = 0; i < n; ++i) {
a[i] = (i % 2 == 0) ? b0.get(i / 2) : b1.get(i / 2);
}

for (int i = 1; i < n; ++i) {
if (a[i] < a[i - 1]) {
return "NO";
}
}

return "YES";
}

public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int T = scanner.nextInt();

while (T-- > 0) {
int n = scanner.nextInt();
int[] arr = new int[n];
for (int i = 0; i < n; ++i) {
arr[i] = scanner.nextInt();
}

System.out.println(isPossibleToSort(n, arr));
}
}
}

```

Python：[此代码未进行大量数据的测试，仅供参考]

```def is_possible_to_sort(n, a):
if n % 2 == 1:
return "YES"

b0 = sorted(a[::2])
b1 = sorted(a[1::2])

sorted_arr = [0] * n
for i in range(n):
sorted_arr[i] = b0[i // 2] if i % 2 == 0 else b1[i // 2]

return "YES" if sorted_arr == sorted(a) else "NO"

T = int(input())
for _ in range(T):
n = int(input())
arr = list(map(int, input().split()))
print(is_possible_to_sort(n, arr))

```

# 第二题

### 题目：小红的相似字符串

2023 秋招笔试题汇总解析 文章被收录于专栏

2023秋招各大笔试题汇总，c++，java，python多种语言分析，解答。