# 《九日集训》第六轮 (第四讲) 指针

``````class Solution {
public int[] shuffle(int[] nums, int n) {
int []res = new int[2 * n];
for(int i = 0; i < n; i++){
res[2 * i] = nums[i];
res[2 * i + 1] = nums[i + n];
}
return res;
}
}
``````

``````class Solution {
public int[] getConcatenation(int[] nums) {
int len = nums.length;
int []res = new int[2 * len];
for(int i = 0; i < len; i++){
res[i] = nums[i];
res[i + len] = nums[i];
}
return res;
}
}
``````

``````class Solution {
public int[] buildArray(int[] nums) {
int []res = new int[nums.length];
for(int i = 0; i < nums.length; i++){
res[i] = nums[nums[i]];
}
return res;
}
}
``````

``````class Solution {
public int[] runningSum(int[] nums) {
int []res = new int[nums.length];
int a = 0;
for(int i = 0 ; i < nums.length; i++){
res[i] = a + nums[i];
a = res[i];
}
return res;
}
}
``````

``````class Solution {
public String reverseLeftWords(String s, int n) {
String res = "";
for(int i = n; i < s.length(); i++){
res += s.charAt(i);
}
for(int i = 0; i < n; i++){
res += s.charAt(i);
}
return res;
}
}
``````
...全文
20 回复 1 打赏 收藏 举报

6.0w+

2022-01-15 15:20

QQ群：480072171