My CS teacher thinks I'm cheating for some reason, what do I say?
You seem to have done exactly the right thing, explaining your work. Just keep insisting that you didn't cheat. It isn't your job to prove your innocence.
And no, there is nothing wrong about learning things other than what has appeared already in lectures.
I'll guess that the professor had an idea about what answers &quot;should be&quot; based on the current point in the course and didn't anticipate using tools not yet introduced. But unless there are clear instructions to the contrary, there is nothing wrong with using what you know.
If you are really accused, then next steps might be to see a student support office or escalate to the department head. But hopefully it won't come to that.