ANSWER:

Consider the numbers between 1-10: 2,3,4,5,6,7,8,9

The fact that neither of them knows the other person's number so they cannot have the extreme values, that are, 2 & 9.

So we are left with 3-8.

Case 1:

If A can immediately guess the number when B doesn't have the solution that means A has a 3 or a 8 and B a 4 or a 7 respectively.

Answer: A=3, B=4

OR

A=8, B=7

Case 2: Similarly A and B can interchange positions

Therefore,

A=4, B=3

OR

A=7, B=8

So these are the four cases.

Hope it answers your question.