Many different readers - who disagree with each other on nearly everything else - will agree that Dostoevsky's Crime and Punishment seems designed as a response to several ideas proposed by Friedrich Nietzsche. Raskolnikov, the main character in Crime and Punishment, embraces an amoral viewpoint and something like the Superman concept; both are central to Nietzsche's thought. Raskolnikov attempts to live out these philosophies, is tortured and frustrated in so doing, and finally finds clarity and peace of mind by rejecting them; seemingly, Dostoevsky's repudiation of Nietzsche's thought.
There is, however, a problem: we lack evidence that Dostoevsky had heard of, or read any of, Nietzsche's writings or ideas. In fact, by the time Crime and Punishment was printed in 1866, Nietzsche had not yet published or written any of his major books. He had published a few smaller and less significant works; it is technically possible that Dostoevsky could have seen them, but they don't contain clear and developed expression of Nietzsche's thought.
So how can Dostoevsky apparently reply to thoughts which hadn't yet been written?
Both Nietzsche and Dostoevsky had access to the same works of earlier authors; both were exposed to intellectual trends of their day. Both had access, for example, to Darwin, Marx, and Kierkegaard. We can see both as responding to them. Nietzsche embracing the deterministic nihilism of Marx and Darwin, rejected Kierkegaard's proposal that humans can engage in a social ethic which acknowledges the value of human life and the possibility of humans making significant and meaningful choices. Dostoevsky, rejecting Darwin and Marx, agreed with Kierkegaard that only by embracing an existential view of human life, crystallized in the act of confession, which simultaneously acknowledges the possibility of responsibility and the hope of redemption, will a human being reach clarity and peace of mind.
So, without having read Nietzsche, Dostoevsky effectively replies to him, because both Nietzsche and Dostoevsky were responding to the same stimuli: Dostoevsky not only gives his response to the stimuli of Darwin, Marx, and Kierkegaard, but peremptorily offers counter-arguments to alternative responses.