public class SortedListsOperations
extends java.lang.Object
Modifier and Type | Method | Description |
---|---|---|
static int[] |
addListsOfNumbers(int[] list1,
int[] list2) |
Adds two lists of numbers and returns calculated sum.
|
static int[] |
convertArrayList2IntArray(java.util.ArrayList<java.lang.Integer> arrayList) |
Auxiliary method which converts given
ArrayList of Integer numbers to array of int numbers |
static boolean |
listOfNumbersContainsNumber(int[] list,
int number) |
Checks if given ascendingly sorted list of integer non-negative numbers contains given number.
|
static int[] |
subtractListsOfNumbers(int[] list1,
int[] list2) |
Subtracts two lists of numbers and returns calculated difference.
|
public static int[] convertArrayList2IntArray(java.util.ArrayList<java.lang.Integer> arrayList)
ArrayList
of Integer
numbers to array of int
numbersarrayList
- array list with Integer
numbersint
numberspublic static int[] addListsOfNumbers(int[] list1, int[] list2)
list1
- first list to add, which should contain ascendingly sorted, non-repeating and non-negative numberslist2
- second list to add, which should contain ascendingly sorted, non-repeating and non-negative numbersInvalidValueException
- when any of input lists is not sorted ascendingly, contains repetitions
or contains negative numberpublic static int[] subtractListsOfNumbers(int[] list1, int[] list2)
list1
- first list, which should contain ascendingly sorted, non-repeating and non-negative numberslist2
- second list, subtracted from first, which should contain ascendingly sorted, non-repeating and non-negative numbersInvalidValueException
- when any of input lists is not sorted ascendingly, contains repetitions
or contains negative numberpublic static boolean listOfNumbersContainsNumber(int[] list, int number)
list
- list of numbers that should be checkednumber
- number searched in the given listtrue
if given list contains given number, false
otherwise