First of all it is not completely right to say that Sanskrit and Hindi both use the Devanagari script.
It is true that Devanagari script is the native script of Hindi, which is also written in other scripts such as Urdu script and roman script (mainly in social media and Hinglish). Sanskrit, on the other hand, has no native script whatsoever and it is written in several scripts in Indian subcontinent and Southeast Asia and it has been so since ancient times. It is quite possible that two Sanskrit speakers (one from North India and second from Thailand) perfectly understand each other while talking but still not be able to understand a single letter of each other's writing.
Letters you are referring to (Lri, Rii etc.) belong to Sanskrit alphabet not the Hindi alphabet. The Devanagari script is not exclusive to Hindi and is used to write alphabets of other languages such as Marathi and Sanskrit as well. As an other example, Marathi alphabet has some letters that are not in Hindi or Sanskrit alphabets but they all use Devanagari script.