1 of 7

ASP

Primeri funkcionalne specifikacije

2 of 7

Input: An array of integers arr.

Output: The value of the largest integer in the array.

Assumptions: The array is not empty.

Example 1:

Input: arr = [1, 5, 2, 9, 3]

Output: 9

Example 2:

Input: arr = [-10, -5, -20]

Output: -5

3 of 7

Input:

An array of integers arr.

A single integer target.

Output: The number of times target appears in arr.

Example 1:

Input: arr = [1, 2, 3, 2, 2, 4], target = 2

Output: 3

Example 2:

Input: arr = [5, 5, 5], target = 5

Output: 3

Example 3:

Input: arr = [1, 2, 3], target = 7

Output: 0

4 of 7

Input: A string s.

Output: A boolean value: true if the string reads the same forwards and backwards, false otherwise.

Assumptions: Ignore case and non-alphanumeric characters for now. Just compare the string as given.

Example 1:

Input: s = "racecar"

Output: true

Example 2:

Input: s = "hello"

Output: false

Example 3:

Input: s = "a"

Output: true

5 of 7

Input: An array of integers arr.

Output: The sum of all integers in the array.

Example 1:

Input: arr = [1, 2, 3, 4]

Output: 10

Example 2:

Input: arr = [5]

Output: 5

6 of 7

Input: An array of integers arr.

Output: The value of the first even number in the array. If there are no even numbers, return -1 (or a special value like None).

Example 1:

Input: arr = [1, 3, 5, 2, 4, 6]

Output: 2

Example 2:

Input: arr = [1, 3, 5, 7]

Output: -1

7 of 7

Input: Two arrays of integers, arr1 and arr2.

Output: A new array that contains all the elements of arr1 followed by all the elements of arr2.

Example 1:

Input: arr1 = [1, 2], arr2 = [3, 4]

Output: [1, 2, 3, 4]

Example 2:

Input: arr1 = ['a'], arr2 = ['b', 'c']

Output: ['a', 'b', 'c'] (This also works for strings!)