There is no solution to this problem. You have two gaps. The pattern suggest by the first four entries (including the first gap as the third entry) suggests a pattern in which each additional change is one less than the last change.
18 + 3 = 21
21 + 2 = 23 (the missing number)
23 + 1 = 24.
This pattern would make the fifth entry (your second gap) also 24
24 + 0 = 24
Then the sixth entry would be 23
24 + -1 = 23
But the sixth entry (30) shows this pattern to be errant.
What actually happened was your teacher was looking for a simple arithmetic progression with each number 3 more than the last and either he/she mistyped when he/she wrote down the problem or you did when you copied it.
It is possible that a much more complicated pattern is at play, but unlikely.