The adverb “seldom” is a negative adverb of frequency.
In formal English, when such adverbs begin a sentence, they require inversion of subject and verb.
The correct form becomes: “Seldom have I encountered such a complicated problem.”
Option analysis:
(A) “I encountered” – no inversion, incorrect.
(B) and (D) – same grammatically, but D is the correct placement.
(C) “When I encountered” – changes sentence structure entirely.
Hence, (D) is the correct answer.