344.反转字符串
accept
27. 移除元素
accept
String s = sc.nextLine();
String[] split = s.split(“,”);
int[] arr = new int[split.length];
arr[i] = Integer.parseInt(split[i]);
public class test {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String s = sc.nextLine();
int val = sc.nextInt();
String[] split = s.split(",");
int[] arr = new int[split.length];
for (int i = 0; i < split.length; i++) {
arr[i] = Integer.parseInt(split[i]);
}
int slow = 0;
for (int fast = 0; fast < arr.length; fast++){
if (arr[fast] != val){
arr[slow++] = arr[fast];
}
}
for (int i = 0; i < slow; i++) {
System.out.print(arr[i] + " ");
}
}