This thesis presents the first measurement of charmed D0 meson production relative to the reaction plane in Pb–Pb collisions at the center-of-mass energy per nucleon-nucleon collision of ?sNN = 2.76 TeV. It also showcases the measurement of the D0 production in p–Pb collisions at ?sNN = 5.02 TeV with the ALICE detector at the CERN Large Hadron Collider. The measurement of the D0 azimuthal anisotropy with respect to the reaction plane indicates that low- momentum charm quarks participate in the collective expansion of the high-density, strongly interacting medium formed in ultra-relativistic heavy-ion collisions, despite their large mass. This behavior can be explained by charm hadronization via recombination with light quarks from the medium and collisional energy loss. The measurement of the D0 production in p–Pb collisions is crucial to separate the effect induced by cold nuclear matter from the final- state effects induced by the hot medium formed in Pb–Pb collisions. The D0 production in p–Pb collisions is consistent with the binary collision scaling of the production in pp collisions, demonstrating that the modification of the momentum distribution observed in Pb–Pb collisions with respect to pp is predominantly induced by final-state effects such as the charm energy loss.