Are you concerned about running time? Has that been discussed yet? Have you talked about efficient data structures for sets? If no, then amit's hint should help you.
If yes, then you should maybe be more clever. You talked about maintaining a set of previously visited vertices when you discussed DFS, yes?
You could instead maintain more than one set with each set meaning something slightly different. You might envision your visited set being the union of these separate sets, but critically you might need to revisit a vertex if it appears in one and then appears in another later.
Ask yourself : What sets might I put vertices into? If a vertex is already joined some set by being visited, when might I need to revisit it? Be careful, you can easily make a mistake here.