An enumerative technique for a class of combinatorial problems