Skip to content

Commit 2ca7d75

Browse files
authored
Improve formatting of example code in readme
Formatted the example code for better readability.
1 parent 6faa290 commit 2ca7d75

File tree

1 file changed

+13
-2
lines changed
  • src/main/java/g0001_0100/s0027_remove_element

1 file changed

+13
-2
lines changed

src/main/java/g0001_0100/s0027_remove_element/readme.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,18 @@ Consider the number of elements in `nums` which are not equal to `val` be `k`, t
1313

1414
The judge will test your solution with the following code:
1515

16-
int[] nums = [...]; // Input array int val = ...; // Value to remove int[] expectedNums = [...]; // The expected answer with correct length. // It is sorted with no values equaling val. int k = removeElement(nums, val); // Calls your implementation assert k == expectedNums.length; sort(nums, 0, k); // Sort the first k elements of nums for (int i = 0; i < actualLength; i++) { assert nums[i] == expectedNums[i]; }
16+
int[] nums = [...]; // Input array
17+
int val = ...; // Value to remove
18+
int[] expectedNums = [...]; // The expected answer with correct length.
19+
// It is sorted with no values equaling val.
20+
21+
int k = removeElement(nums, val); // Calls your implementation
22+
23+
assert k == expectedNums.length;
24+
sort(nums, 0, k); // Sort the first k elements of nums
25+
for (int i = 0; i < actualLength; i++) {
26+
assert nums[i] == expectedNums[i];
27+
}
1728

1829
If all assertions pass, then your solution will be **accepted**.
1930

@@ -37,4 +48,4 @@ If all assertions pass, then your solution will be **accepted**.
3748

3849
* `0 <= nums.length <= 100`
3950
* `0 <= nums[i] <= 50`
40-
* `0 <= val <= 100`
51+
* `0 <= val <= 100`

0 commit comments

Comments
 (0)