Message from C, C++ talks
First learn the concepts ,try applying them by framing ur own simple questions.
Who asked you to mess ur brain reading complete question in hackerrank. Just look at the sample input and output. Write the code if it fails then look into question a little bit.