Use of cin.get() in the code

Why cin.get() is used after cin>>n in the coding part of this question?

Hello @amartyaprabhakar
whenever you use cin before getline(cin,s) you have to use cin.get()
this is because Assuming you have pressed enter after taking input n using cin , the newline character was also put on the stream. When you call cin.get() after that, it will grab and discard the newline character, allowing the rest of your code to properly get the input.

Also sir i have a very basic doubt… Can you please suggest whether i should make notes while following lectures or not, if yes then how?

Hello @amartyaprabhakar i think you should go for understanding if anything you are not able to understand then
you should take the note of that only.
and after few days you are not able to implement that also then you should try to understand that again.
you can take help from us if you are not able to understand anything.
try to understand everything instead of making notes.