You are on page 1of 2

Bài

1 – Chủ đề: Array Functions


Đề bài:

Zipper

The method zipMany() has n different arrays as input. The signature is therefore int[ ]
zipMany(int[ ][ ] arrays). The numbers from the input arrays should be inserted alternately
into the result array. Arrays that have already been completely processed should also be
skipped until all values of the input arrays have been used up. If the input array is empty, an
empty array is returned.

For example: with arrays=[ [1,4], [2, 5], [3, 6] ], the result should be [1, 2, 3, 4, 5, 6].

Sorting out

The public static int[] filter(int[] array, int min, int max) method removes numbers from the
array that are not within a specified interval. The interval is given by 2 integers, each including
the largest and smallest allowed value. If all numbers outside the interval have been filtered
out, the returned array is correspondingly smaller, but the order of the allowed numbers
remains the same. If the largest allowed value is less than the smallest allowed value, no value
can satisfy this criterion and the result is an empty array.

Rotation

The method public static void rotate(int[] array, int amount) should rotate the entries of array
backwards by amount. I.e. all entries are to be shifted backwards by amount, with the last
element coming back to the front when rotated by 1.

For example, if you use the array:


rotated by 2, you get the array:


1, 2 and 3 were moved backwards by 2.

4 and 5 would have fallen off the bounds of the array, ending up in front again.


Rotation around a negative number corresponds to a rotation in the other direction (to the
left), rotation around a number with an amount ≥ array.length simply rotates it completely
multiple times. If you e.g.:


rotated by -1, you get the array:


if you:


rotated by 6, you get the array:


Any int can be passed for amount, a valid rotation always results.

You might also like