Consider the positive coordinate axes. Let points on the positive x axis denote the times at which A arrives and the points on the y axis denote the times at which B arrives. Let the origin denote 8 a.m. 1 unit on each axis is equal to 1 hour. So all possibilities are included in the square S with opposite vertices (0,0) and (1,1) with 0 denoting 8 a.m and 1 denoting 9 a.m. For example, the event that A arrives at 8:30 a.m and B arrives at 8:45 a.m is denoted by the point (1/2, 3/4).
Let x be the time at which A arrives and y be the time at which B arrives. The constraints are x-y < 1/3 and y-x < 1/3 with 1/3 representing 20 minutes (1/3 hour). Draw these lines on the square S. The area enclosed between these lines and the square divided by the area of the square is the required probability. 5/9 is the answer.
You can also work this out using calculus. Assume arrival times in a unit time interval representing the time period from 8 a.m to 9 p.m follow a uniform distribution. Suppose A arrives at time x then B must arrive within 20 minutes (1/3 hour) before or after A for them to meet. The chance of this happening depends on x. There are three cases-
x < 1/3, 1/3 <= x < 2/3, 2/3 <= x < 1
Case 1: B must arrive in the first x + 1/3 of [0,1] interval. Probability of this is (x + 1/3)/1 (uniform distribution). So probability that A and B meet given A arrives at x is (x + 1/3) dx.
Case 2: B must arrive within 1/3 hour before or after x. Probability that A and B meet given A arrives at x is 2/3 dx.
Case 3: B must arrive within the last 1/3 + 1 - x hours. Probability that A and B meet given A arrives at x is (1/3 + 1 -x) dx.
Integrate each of the expressions between the appropriate limits (Case 1: 0 to 1/3), (Case 2: 1/3 to 2/3) and (Case 3: 2/3 to 1) and add the integrals to get the answer.