**In the name of Allah, the most compassionate, the most merciful**

briefly speaking, typically, the first who intends to say hello (as a greeting), he or she says:

 - Assalamu Alaikum

But the second one who want to reply to his or her saying hello, tells:

 - Alaikum Salam. (which demonstrates being the second part who is
   saying back his/her hello

Otherwise seemingly you can use both of these two forms in replying, although "AlaikumoSalam looks to be more accurate in compare with other form.