# Problem

This function takes an array and a number, and returns a new array that contains all elements of the input array that are divisible by the given number.

```
def filter_by_divisibility(arr, divisor):
new_arr = []
for i in range(len(arr)):
if arr[i] % divisor == 0:
new_arr.append(arr[i])
return new_arr
```

# Solution

You may apply the three-step process, but it's evident that the number of loops is determined by the size of the array. The operations inside the loop are constant-time. It follows that the time complexity is $O(N)$.

##### This workbook was created by Jad and Rayan Slim. Feel free to explore some of their courses:

##### The Complete Java Development Bootcamp

##### The Complete Spring Boot Development Bootcamp – Become a Java Web Developer

Feedback Summary

0.0

0 students

5

0%

4

0%

3

0%

2

0%

1

0%

Written Reviews

There are no written reviews yet.