We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a56ebbf commit d0fd9f4Copy full SHA for d0fd9f4
src/task_27/Solution.java
@@ -0,0 +1,32 @@
1
+package task_27;
2
+
3
+import java.util.ArrayList;
4
+import java.util.Arrays;
5
+import java.util.LinkedList;
6
+import java.util.List;
7
8
+public class Solution {
9
10
+ public int removeElement(int[] nums, int val) {
11
+ Arrays.sort(nums);
12
+ int amountOfDeletions = 0;
13
+ for (int i = 0; i < nums.length; i++) {
14
+ if (nums[i] == val) {
15
+ delete(nums, i);
16
+ amountOfDeletions++;
17
+ nums[nums.length - 1] = 51;
18
+ }
19
20
+ i--;
21
22
23
+ return nums.length - amountOfDeletions;
24
25
26
+ public void delete(int[] array, int index) {
27
+ for (int i = index; i < array.length-1; i++) {
28
+ array[i] = array[i+1];
29
30
31
32
+}
0 commit comments