👩💻 Join our community of thousands of amazing developers!
667.优美的排列 IIJAVA12345678910111213141516171819class Solution { public int[] constructArray(int n, int k) { int[] answer = new int[n]; int idx = 0; for (int i = 1; i < n - k; ++i) { answer[idx] = i; ++idx; } for (int i = n - k, j = n; i <= j; ++i, --j) { answer[idx] = i; ++idx; if (i != j) { answer[idx] = j; ++idx; } } class Solution { public int[] ...