Charge on capacitor after charging with a battery of potential V, Q=CV
Now, capacitor A is connected as shown in the figure.

As diode is in reverse bias, so capacitor charge remains same after time t=CR.
∴QA=CV
In case B, capacitor is connected as shown in the figure.

Here, diode is in forward bias, so capacitor discharges and its charge decays as
QB=Q⋅eRC−t
where, t=RC
