I doubt the interviewer's goal was to find out if you know the Floyd cycle-find algorithm. The goal of such a question would be to understand whether you understand the concepts of data structures such as lists, binary trees, and hashes.
The main problem with your answer is that the algorithm you provided has complexity O (n ^ 2), i.e. O (n) to move the original list * O (n) to check if each node exists in the second list, by every iteration.
When the interviewer asked you to optimize your answer, you could suggest replacing the second linked list with a different data structure that provides a quick search than O (n). For example, a binary tree has O (logn) search complexity, and a hash has O (1) search complexity (not always, but this is a generally accepted assumption), which is much faster than using a second linked list that has O (n) search complexity.
So the O (n) solution should replace your second linked list with a hash (i.e. HashMap, HashSet, etc.).
Of course, the Floyd cycle-find algorithm is a more elegant solution to this problem, since it has better memory complexity (i.e. there is no need to store the visited nodes in memory).
source share