We address the invertibility problem for switched systems, which is the problem of recovering the switching signal and the input uniquely given an output and an initial state. In the context of hybrid systems, this corresponds to recovering the discrete state and the input from partial measurements of the continuous state. In solving the invertibility problem, we introduce the concept of singular pairs for two systems. We give a necessary and sufficient condition for a switched system to be invertible, which says that the individual subsystems should be invertible and there should be no singular pairs. When the individual subsystems are invertible, we present an algorithm for finding switching signals and inputs that generate a given output in a finite interval when there is a finite number of such switching signals and inputs. Detailed examples are included. Published by Elsevier Ltd.