Studying for an exam with an unprepared student I am a student and another student asked me to study together for an exam and I agreed. But when we started studying he didn't know much about the subject, and I had to explain to him how to solve the problems and waste a lot of time in doing so.

Should I keep studying with him?
Ask yourself what you are getting out of it. If nothing, then give it up and just advise the student to study harder. 

But it is just possible that you are benefitting from the experience. Having to explain things to others firms up your own understanding in many fields. Many professors have had the experience that teaching a relatively low level course for the first time gave them a deeper understanding. Even something like, say, calculus. 

One of the most important aspects to learning is reinforcement and feedback. Depending on the other student's questions and issues, you may be getting both from the interaction. 

Think about it and also think about your best use of the time. Active learning (as in such a scenario) may be more effective than passive (reading notes, say).