So the difficulty to this question is the phrasing of it. You know:
-1/3 of the JOB was done in 5 days with 49 painters.
We let the following variables:
-$p$ be the number of painters
In this case, the rate, $r_1$, of the first batch of workers are:
$$r_1=\frac{1/3 JOB}{\text{5 days} \cdot \text{49 painters}}=\frac{1}{15\cdot49}\frac{JOB}{\text{painter}\cdot\text{day}}$$
Then, we know there is 2/3 of the JOB left to be done in 7 days. So we state that the rate of the first batch times the remaining time and size of the first painter batch, with the rate of the second batch times the remaining time and size of the second painter batch, should equal 2/3:
$$r_1\cdot49\text{painters}\cdot7\text{days}+r_2\cdot p\text{ painters}\cdot7\text{days}=\frac{2}{3}$$
Therefore, since we know the second batch of painters will have the same rate, $r_1=r_2$, we say:
$$(49+p)\text{painters}\cdot7\text{days}\cdot r_1=\frac{2}{3}$$
So we simplify:
$$(49+p)\text{painters}=\frac{2}{21r_1}\text{painters}$$
$$p=\frac{2}{21r_1}-49$$
Insert $r_1$ and simplify and you should obtain the number of painters