Who is a subject pronoun and should be used to replace the subject of the verb.
Whom is an object pronoun and should be used either to replace the object of a verb or before a preposition.
A simple test is to see whether you can replace the who/whom with a subject pronoun (I or he) or an object pronoun (me or him).
Whom did you see? (Did you see him?)
I cannot see who is in the classroom. (He is in the classroom.)
To whom it may concern. (To him...)
Who has lost their shoes? (He has lost his shoes.)